Angular2 Router - Anyone know how to use canActivate in app.ts so that I can redirect to home page if not logged in
问题 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. Current attempt under my constructor in my app.ts file: canActivate(instruction) { console.log("here - canActivate"); console.log(instruction); this.router.navigate(['Home']); } It currently doesnt get hit. Any idea why? 回答1: So the documentation looks like this is what it exports. export CanActivate(options : CanActivateAnnotation) : (hook: