标签:class guard port tor adc boolean ble this turn
‘canLoad‘ guard can decide whether a lazy load module can be loaded or not.
@Injectable()
export class CanLoadPokemon implements CanLoad { constructor(private authService: AuthService) { } canLoad(route: Route): Observable<boolean>|Promise<boolean>|boolean { return this.authService.isAuth; } }
app.routers.ts:
{path: ‘home‘, loadChildren: ‘app/home/home.module‘, data: {title: ‘Pokemon List‘}, canLoad: [CanLoadPokemon]},
So if user not login, app won‘t load home module.
[Angular2 Router] Guard: CanLoad
标签:class guard port tor adc boolean ble this turn
原文地址:http://www.cnblogs.com/Answer1215/p/6130040.html