Reputation: 508
I was wondering if there is an alternative to
$rootScope.$on("$stateChangeStart", function() {});
Because I want to get that event on many pages which do different things. If I use the way above, this event is fired for every page I implemented it (even if the page wasn't where I came from or wasn't where I go to)...which is a little overheading.
So what I am looking for is an event which is fired only if the controller is used on the current page.
Upvotes: 0
Views: 1059
Reputation: 39
use $stateChangeStart instead of $routeChangeStart
there are some differences between Angularjs ngRoute and ui-router.
http://www.amasik.com/angularjs-ngroute-vs-ui-router/
Upvotes: 2
Reputation: 2653
Sure. Just use the event $routeChangeStart:
$scope.$on('$routeChangeStart', function(){
console.log(arguments);
});
Upvotes: 0