javascript - Navigation partial not updating even though controller $scope has new value -


we building project client involves dynamic navigation bar, angular-local-storage module, authorization service, data service, , 2 partial, 1 navigation bar partial , other header partial. logging user in via authservice , retrieving navigation elements server http.get call. value stored in localstorage element called navelements. code follows :

index:

<div class="main-container">         <aside data-ng-include=" 'views/nav.html' "                id="nav-container"                class="nav-container"                data-ng-class=" {'nav-fixed': admin.fixedsidebar, 'nav-horizontal': admin.menu === 'horizontal', 'nav-vertical': admin.menu === 'vertical'}"                >         </aside>          <div id="content" class="content-container">             <section data-ng-view                      class="view-container {{admin.pagetransition.class}}"></section>         </div>     </div> 

login / nav element placement

apirequest(api_url + 'navigation').then(     function(event){        console.log(event);        localstorageservice.set("navelements", event);        modalinstance.close();         deferred.resolve(response);        $location.url('/dashboard'); } 

navigation html

<div class="nav-wrapper" data-ng-controller="dashboardctrl"> <ul id="nav"     class="nav"     data-slim-scroll     data-collapse-nav     data-highlight-active>     <li ng-if="initialized"><a href="#/dashboard"> <i class="ti-home"></i><span data-i18n="dashboard"></span> </a></li>      <li ng-repeat="nav in navlist">         <a href="{{nav.buttonpath}}" disabled>             <i class="{{nav.iconpath}}"></i>             <span data-i18n="{{nav.title}}"></span>         </a>         <ul>             <li ng-repeat="link in nav.children">                 <a href="{{link.navigationurl}}">                     <i class="ti-angle-right"></i>                     <span data-i18n="{{link.title}}"></span>                 </a>             </li    >         </ul>     </li>  </ul> 

and dashboard controller nav list assignment:

angular.module('app.dashboardctrl', []).controller('dashboardctrl',function ($q, $http, $scope, $location, $route, $window,  $modal, dataservice, logger, localstorageservice) {    $scope.editmode=false;    $scope.rows = {};    $scope.currentlocation = "";     console.log($scope);     $scope.navlist = localstorageservice.get("navelements"); 

the strange part elements appear after page reloaded on initial login after clearing cookies, nav elements not exist. however, nav elements reside in $scope of controller , $scope.$apply not work, time out. console.log shows $scope.navlist defined user logs in , brought dashboard view. pretty stumped issue , / suggestions wonderful. issue exists part of page suspect related.

i determined causing issue in first place. html loading multiple controllers handle various requests on page. fix issue removed multiple controllers each page , made 1 controller per page handled various functions need on each respective page. appear actual scopes , data being lost in multiple controllers.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -