feat(router): add "paramsInheritanceStrategy" router configuration option

Previously, the router would merge path and matrix params, as well as
data/resolve, with special rules (only merging down when the route has
an empty path, or is component-less). This change adds an extra option
"paramsInheritanceStrategy" which, when set to 'always', makes child
routes unconditionally inherit params from parent routes.

Closes #20572.
This commit is contained in:
Zaven Muradyan
2017-11-28 16:57:10 -08:00
committed by Alex Rickabaugh
parent 5f23a1223f
commit 5efea2f6a0
10 changed files with 200 additions and 44 deletions

View File

@ -3794,6 +3794,19 @@ describe('Integration', () => {
});
});
describe('Testing router options', () => {
describe('paramsInheritanceStrategy', () => {
beforeEach(() => {
TestBed.configureTestingModule(
{imports: [RouterTestingModule.withRoutes([], {paramsInheritanceStrategy: 'always'})]});
});
it('should configure the router', fakeAsync(inject([Router], (router: Router) => {
expect(router.paramsInheritanceStrategy).toEqual('always');
})));
});
});
function expectEvents(events: Event[], pairs: any[]) {
expect(events.length).toEqual(pairs.length);
for (let i = 0; i < events.length; ++i) {