javascript - Angular ngRoute conditional .when() -
i'd implement conditional .when(), this:
.when('/abc', { // if myservice.allow == true template: '<mydirec></mydirec>' // else redirectto: '/' })
my /abc
route shall "secured" variable hold in 1 of services, in stateful manner. want set state somewhere else true/false , next time user tries /abc served conditionally.
how can achieve this? - few 3rd-party dependencies possible
what tried , read about: - injecting service in .config, learnt not possible - read using provider can injected. can use them use service? - template , templateurl accept function, didn't me
thanks in advance!
you use $routechangestart event. it's fired when url changed , takes current , next arguments like:
$rootscope.$on('$routechangestart', function(event, next, current) { if (next === 'abc') // something; });
Comments
Post a Comment