javascript - Right approach to choose which directive to print Angular -


here scenario.

i'm making $.get() request server know role of user, eg if user administrator, normal user or user elevated privileges. once value php $_session return json object parse , start checking if of users mentioned above:

$scope.getmenutype = function(){         $.get('controllers/getusertype.php', function(result){             dataforhubmenu = $.parsejson(result);             console.log(dataforhubmenu);             if(dataforhubmenu.usertype == 'normal'){                 $scope.menutype = '<normal-menu></normal-menu>';             } else if(dataforhubmenu.usertype == 'admin'){                 $scope.menutype = '<administrator-menu></administrator-menu>';             } else if(dataforhubmenu.usertype == 'director'){                 $scope.menutype = '<director-menu></director-menu>';             }         });     }; 

then trigger function inside controller on line below:

$scope.getmenutype(); 

once this, expect variable $scope.menutype has right jquery object print. , inside html following:

<div ng-controller="hubcontroller hub" class="container">     <div class="row">         <div class="col-md-6 col-md-offset-3">             <div class="well">                 <h1 class="text-center">panel de control</h1>                 <hr>                 {{hub.menutype}}             </div>         </div>     </div> </div> 

inside chrome console try console.log() value of menutype see if variable has value, get:

console.log(angular.element($(".container")).scope().menutype); undefined vm2228:2 undefined 

the console.log() occurs inside controller , inside console on chrome, output same on both cases.

i'm not sure why happening. directives follow:

app.directive("administratormenu", function(){     return {restrict: 'e', templateurl: "views/admin-menu.html"} }); app.directive("normalmenu", function(){     return{restrict: 'e', templateurl: "views/normal-menu.html"} }); app.directive("directormenu", function(){     return{restrict: "e", templateurl: "views/director-menu.html"} }); 

any idea might doing wrong? right approach i'm trying do. i'm finished angular course @ codeschool , i'm trying out advanced features in small project.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -