IONIC4新特性-生命周期方法

The CanActivate and CanDeactivate interfaces can be used to implement the same type of logic that the removed events ionViewCanEnter and ionViewCanLeave did.

 

例子:

@Injectable()
export class AuthGuard implements CanActivate {
  constructor(private authService: AuthService) {}

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    return this.authService.isAuthenticated();
  }
}

 

 


版权声明:本文为liweibo348原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。