feat(router): add an extra argument to CanDeactivate interface (#13560)

Adds a `nextState` argument to access the future url from `CanDeactivate`.

BEFORE:

    canDeactivate(component: T, route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean;

AFTER:

    canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean;

Closes #9853
This commit is contained in:
Dzmitry Shylovich
2016-12-28 01:08:06 +03:00
committed by Hans
parent 445ed43b9a
commit 69fa3bbc03
4 changed files with 75 additions and 8 deletions

View File

@ -985,9 +985,10 @@ export class PreActivation {
const guard = this.getToken(c, curr);
let observable: Observable<boolean>;
if (guard.canDeactivate) {
observable = wrapIntoObservable(guard.canDeactivate(component, curr, this.curr));
observable =
wrapIntoObservable(guard.canDeactivate(component, curr, this.curr, this.future));
} else {
observable = wrapIntoObservable(guard(component, curr, this.curr));
observable = wrapIntoObservable(guard(component, curr, this.curr, this.future));
}
return first.call(observable);
});