mapToCanDeactivate
Maps an array of injectable classes with canDeactivate functions to an array of equivalent CanDeactivateFn for use in a Route definition.
API
function mapToCanDeactivate<T = unknown>( providers: Type<CanDeactivate<T>>[], ): CanDeactivateFn<T>[];
@returns
CanDeactivateFn<T>[]
Description
Maps an array of injectable classes with canDeactivate functions to an array of equivalent CanDeactivateFn for use in a Route definition.
Usage
@Injectable({providedIn: 'root'})
export class AdminGuard {
canActivate() {
return true;
}
}
const route: Route = {
path: 'admin',
canActivate: mapToCanActivate([AdminGuard]),
};
Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/router/mapToCanDeactivate