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']);       }     }   )     } 

https://angular.io/api/router/router


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -