W3cubDocs

/Angular

mapToCanActivateChild

function

Maps an array of injectable classes with canActivateChild functions to an array of equivalent CanActivateChildFn for use in a Route definition.

See more...

mapToCanActivateChild(providers: Type<{ canActivateChild: CanActivateChildFn; }>[]): CanActivateChildFn[]

Parameters
providers Type<{ canActivateChild: CanActivateChildFn; }>[]
Returns

CanActivateChildFn[]

See also

Description

Usage

@Injectable({providedIn: 'root'})
export class AdminGuard {
  canActivate() {
    return true;
  }
}

const route: Route = {
  path: 'admin',
  canActivate: mapToCanActivate([AdminGuard]),
};

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/router/mapToCanActivateChild