angular2 routing - Setting up authentication Angular 2 for new router (>= rc1) -
i got authentication , running angular 2 app trying upgrade new router, removing router-deprecated. problem strategy doesn't work anymore.
in old router, extended router-outlet check if url able activate. if wasn't, redirected login page.
in new router however, router-outlet doesn't exist anymore. new best strategy?
one option subscribe router in order evaluate whether user logged in whenever route changes, in appcomponent:
constructor (private _router: router) {} ngoninit(){ this._router.subscribe( next => { if (!userisloggedinorwhatever) { this._router.navigate(['login']); } } ) }
Comments
Post a Comment