CanActivateChild

CanActivateChild

Stable Interface

What it does

Interface that a class can implement to be a guard deciding if a child route can be activated.

How to use

class UserToken {}
class Permissions {
  canActivate(user: UserToken, id: string): boolean {
    return true;
  }
}

@Injectable()
class CanActivateTeam implements CanActivateChild {
  constructor(private permissions: Permissions, private currentUser: UserToken) {}

  canActivateChild(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
  ): Observable<boolean>|Promise<boolean>|boolean {
    return this.permissions.