Angular2 Router - Anyone know how to use canActivate in app.ts so that I can redirect to home page if not logged in
I\'m using typescript and angular 2.
From here:
https://angular.io/docs/ts/latest/api/router/CanActivate-decorator.html
CanActivate is an annotation, not a function. You use it like this:
@Component({selector: ... })
@CanActivate(()=>console.log('Should the component Activate?'))
class AppComponent {
}
routerOnActivate IS a function you use inside your component:
https://angular.io/docs/ts/latest/api/router/OnActivate-interface.html