What i am trying to do
As mentioned in questions title, i want to check authorization and authentication of next routes so i have made custom properties on routes and trying to access them in $locationChageStart.
Problem i am facing is
the event
, next
, prev/current
arguments are correct but custom properties are returning undefined
My code
myModule.run(function($rootScope,authService,$state){
$rootScope.$on("$locationChangeStart",function(e,next,prev){
console.log(e+","+next+","+prev); //correct
console.log(next.reqAuthentication); // returning undefined
console.log(prev.reqAuthentication); // returning undefined
});
})
and in Config routes are like
.state('profile.company', {
url: "/company",
templateUrl: 'partials/companyprofile.html',
controller: 'adminCtrl',
reqAuthentication:true,
authenticateRole:['a','b',"c"]
})
.state('profile.messages', {
url: "/messages",
templateUrl: 'partials/chat.html',
controller: 'adminCtrl',
reqAuthentication:true,
authenticateRole:['a','b',"b"]
})
Note: I am using ui routes so i think there is some problem i am mixing it up with ngRoute