mi sto muovendo da AngularJS 1,3 a AngularJS 1.4. E questa volta sto usando AngularJS new route ad es. ngNewRouter
introdotto in AngularJS 1.4.
Il mio codice di esempio è il seguente:
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.");
});
}]);
Routing sta lavorando bene, ma $ routeChangeSuccess non è sempre chiamato mai :(
potrebbe essere $ routeChangeSuccess Lister sarà chiamato con. Solo modulo ngRoute
e sto utilizzando ngNewRouter
anziché ngRoute
. Se è vero, allora quale listatore dovrei eseguire il binding al posto di $ routeChangeSuccess?