feat(router): allow CanLoad guard to return UrlTree (#36610)

A CanLoad guard returning UrlTree cancels current navigation and redirects.
This matches the behavior available to `CanActivate` guards added in #26521.

Note that this does not affect preloading. A `CanLoad` guard blocks any
preloading. That is, any route with a `CanLoad` guard is not preloaded
and the guards are not executed as part of preloading.

fixes #28306

PR Close #36610
This commit is contained in:
Andrew Scott
2020-04-13 10:50:44 -07:00
committed by Andrew Kushnir
parent cae2a893f2
commit 00e6cb1d62
4 changed files with 150 additions and 66 deletions

View File

@ -64,7 +64,7 @@ export declare interface CanDeactivate<T> {
}
export declare interface CanLoad {
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean;
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
}
export declare class ChildActivationEnd {