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
Post a Comment