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

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -