javascript - Run function on every route change -


i have app built on angular.js, , want run function whenever route changed , new template rendered in view. found way in controller when activated, this:

$scope.$on('$routechangestart', function(next, current){     //...do stuff here... }); 

but there way run function on each route change, have enter once?

if view

<div ng-app='myapp'>    <ng-view/> </div> 

change to

<div ng-app='myapp' ng-controller='rootcontroller'>    <ng-view/> </div> 

in rootcontroller can add event handler $routechangestart. since rootcontroller created once , remains lifetime of app can safely subscribe event here.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -