javascript - rootScope gets undifined when changing route -


so, when user logs in have code

var promise = userfactory.dologin(usercredentials);  promise.success(function (data, status) {     //set localstorage vars   //only on login's success additional data     var anotherpromise = userdatafactory.getuserdata();                                        anotherpromise.success(function (data, status){                                                  if(data.code == 2){                                                                     $rootscope.userhead = true;              }  }); 

$rootscope.userhead = true; show/hide sub-menu according value (true/false). sub-menu's html is

<div class="panel panel-default text-center" style="text-align: center;" ng-hide="userheader">

the page includes menu, included in pages <div id="submenu" ng-include="'submenu.html'" ></div>. pages in routes so

            .when('/user', {                                    templateurl: 'user.html',                                         controller: 'usercontroller',                animation: 'second',                access: {                     requiredlogin: true                 }             })             //user.html includes menu ng-include="'submenu.html'" 

when go user page, $rootscope.userhead has value , sub-menu hidden should be. if hit refresh, $rootscope.userhead undifined , can see submenu.

i dont see overwrite $rootscope.userhead. looses value when go page? shouldnt keep value?

what missing? how fix this?

thanks

if reload page information store in javascript variables lost. $rootscope nothing more variable in javascript. if want store persists page reload there @ least following possibilities:

author: micheal.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -