For a route defined like this:
$routeProvider
.when(\'/\',
{
templateUrl:\'views/login.html\',
controller:\'Login\',
private:false
});
$routeChangeStart
happens prior to the route changing, so you need to look at next
. There's no need to use next.$$route
since next inherits from $$route
.
angular.module('example', ['ngRoute'])
.config(function($routeProvider) {
$routeProvider.when('/', {
controller: 'MyCtrl',
template: 'isPrivate: {{isPrivate}}',
private: false
});
})
.run(function($rootScope) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
/*
* this is fired prior to the route changing, so your params will be on
* next. Here we just attach it $rootScope as an example.
* note that you don't need to use next.$$route since $$route is private,
* and next inherits from next.$$route. */
*/
$rootScope.isPrivate = next['private'];
});
})
.controller('MyCtrl', function($scope) {
})