• 개요
@angular/router

mapToCanActivate

함수
안정화

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[];
@paramprovidersType<CanActivate>[]
@returnsCanActivateFn[]

설명

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

Usage

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

const route: Route = {
  path: 'admin',
  canActivate: mapToCanActivate([AdminGuard]),
};
상세 내용으로 이동