angular - Execute base component before using route component for auth -


i have small sample application loads various components based on routes in angular 2 (using typescript).

what i'd try next way auth checking before the actual component belongs route called.

i example create sort of base class , let of component classes extend that. have make sure of components call constructor of base class.

but perhaps there more "angular 2" way achieve same goal?

i haven't found info on matter yet. there way trigger, let's authcomponent class before other component loaded?

check @canactivate annotation:

https://angular.io/docs/ts/latest/api/router/canactivate-decorator.html

you can prevent component getting instantiated , reroute them login.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -