feat(router): add pathParamsChange mode for runGuardsAndResolvers (#26861)
This option means guards and resolvers will ignore changes to optional parameters such as query and matrix params. When the path or any path params change, guards and resolvers will be run Related to discussion in #18253 FW-560 #resolve PR Close #26861
This commit is contained in:

committed by
Andrew Kushnir

parent
3da82338d1
commit
bf6ac6cef8
@ -11,6 +11,7 @@ import {Injector} from '@angular/core';
|
||||
import {LoadedRouterConfig, RunGuardsAndResolvers} from '../config';
|
||||
import {ChildrenOutletContexts, OutletContext} from '../router_outlet_context';
|
||||
import {ActivatedRouteSnapshot, RouterStateSnapshot, equalParamsAndUrlSegments} from '../router_state';
|
||||
import {equalPath} from '../url_tree';
|
||||
import {forEach, shallowEqual} from '../utils/collection';
|
||||
import {TreeNode, nodeChildrenAsMap} from '../utils/tree';
|
||||
|
||||
@ -147,6 +148,9 @@ function shouldRunGuardsAndResolvers(
|
||||
curr: ActivatedRouteSnapshot, future: ActivatedRouteSnapshot,
|
||||
mode: RunGuardsAndResolvers | undefined): boolean {
|
||||
switch (mode) {
|
||||
case 'pathParamsChange':
|
||||
return !equalPath(curr.url, future.url);
|
||||
|
||||
case 'always':
|
||||
return true;
|
||||
|
||||
|
Reference in New Issue
Block a user