Transitioning from AngularJS 1.3 to AngularJS 1.4 has brought about some changes, including the use of AngularJS's new route method known as ngNewRouter
, specifically introduced in AngularJS 1.4.
Below is a snippet of my code:
var versionModule = ng.module('test', ['ngNewRouter']);
versionModule.controller('TestController', ['$rootScope', '$router', function ($rootScope, $router) {
var version = this;
$router.config([
{
path: '/',
redirectTo: '/home'
},
{
path: '/home',
component: 'home'
}
]);
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
console.log("This line is not getting printed ever.");
});
}]);
The routing functionality is working fine, however, the $routeChangeSuccess event is not firing at all.
It seems that the $routeChangeSuccess event listener may only work with the ngRoute
module, whereas I am using ngNewRouter
instead of ngRoute
. If this is the case, what event listener should I use in place of $routeChangeSuccess ?