angularjs - $rootScope value undefined -


i'm defining rootscope variable after making login in application, strange thing value declared in parts undefined.

 $rootscope.username = data.nombre;  $rootscope.userimage = data.photo; 

these variables declared , contain value because have checked, example. variable defined in logincontroller, use in homectrl , works quite well. use in declaration of menu fails , not recognized.

edit

in state need pass value of variable , can not not service (not not work can not think way) thought $ rootscope work. state has no controller according defini needed guidance on how run driver pass variables need displayed.

.state('eventmenu', {   url: "/event",   abstract: true,   templateurl: "event-menu.html" }) 

some more code have been helpful, controller using $rootscope. given data can point common pitfall: not injecting $rootscope in controller. $rootscope being service needs injected in controller. example:

module.controller('mycontroller', ['$scope', '$rootscope',function($scope, $rootscope) {   ... }]); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -