• Overview
@angular/router

mapToCanActivate

function

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

API

  
    function mapToCanActivate(  providers: Type<CanActivate>[]): CanActivateFn[];
  
  

mapToCanActivate

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

Usage {@example router/utils/functional_guards.ts region='CanActivate'}

@paramprovidersType<CanActivate>[]
@returnsCanActivateFn[]

Description

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

Usage ```angular-ts @Injectable({providedIn: 'root'}) export class AdminGuard { canActivate() { return true; } }

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

Jump to details