Reputation: 1309
Following is my sample route config.
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/admin', {
templateUrl: 'admin/admin.html',
controller: 'AdminCtrl'
}).when('/admin/confrence',{
templateUrl: 'admin/adminconfrence.html',
controller: 'AdminCtrl'
}).when('/admin/confrence/new',{
templateUrl: 'admin/adminconfrencenew.html',
controller: 'AdminCtrl'
});
}])
I want to do some authentication check when ever any route is called which is beginning /admin
. Can someone please guide me how it's possible
Upvotes: 0
Views: 44
Reputation: 13763
Try this:
app.run(function($rootScope) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (next.$$route.originalPath.indexOf("/admin")!= -1){
// do your stuff
}
});
})
Upvotes: 3