angularjs - Reset a $rootScope property on location change in Angular.js -


in application have $rootscope property called $rootscope.currentstatus used set css class on body under circumstances.

the problem need reset value default time user leaves current page, don't know can intercept location change. use $routeprovider:

app.config(function ($routeprovider, $locationprovider, $httpprovider) {        $routeprovider.when('/site/dashboard', {         templateurl: '/partials/site/dashboard.html',         controller: 'dashboardcntl',         resolve: {             loggedin: checkloggedin         }     });      .... }); 

with many entries. use resolve adding function reset variable i'd have insert in on routing entries.

do have other idea?

ok, found solution myself, can intercept location change (route change) using code:

$scope.$on('$routechangesuccess', function (next, current) {      $rootscope.currentstatus = "";  }); 

so don't have reset variable in of routing entries, reset when route changes , set proper value inside controller.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -