I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
UrlMatcher function is called twice on navigation
Expected behavior
UrlMatcher should be called once
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-router-basic-example-wdvkbt?file=app/app.routing.module.ts
As You can see, on each navigation UrlMatcher is called twice. What's even weirder is that group argument is different each time - one has parent and one doesn't.
What is the motivation / use case for changing the behavior?
Originally I wanted to create matcher that would match route only if You are in specific named outlet:
export function parentOutletMatcher(outlet: string): UrlMatcher {
return (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => {
if (group.parent && group.parent.children[outlet] === group) {
return { consumed: [] };
}
return null;
};
}
So I could use one lazy-loaded module to define routes for many named outlets, example:
const ROOT_ROUTES = [
{ path: 'feature', loadChildren: './lazy.module.ts#LazyModule' },
{ path: 'feature', outlet: 'modal', loadChildren: './lazy.module.ts#LazyModule' },
{ path: 'feature', outlet: 'settings', loadChildren: './lazy.module.ts#LazyModule' },
];
// in lazy.module.ts:
const LAZY_ROUTES = [
{ matcher: parentOutletMatcher(PRIMARY_OUTLET), children: [
// ...
]},
{ matcher: parentOutletMatcher('modal'), children: [
// ...
]},
{ matcher: parentOutletMatcher('settings'), children: [
// ...
]},
]
But because of router's weird behavior this doesn't work.
Environment
Angular version: 6.1.8
Browser:
- [x] Chrome (desktop) version XX
I'm submitting a...
Current behavior
UrlMatcherfunction is called twice on navigationExpected behavior
UrlMatchershould be called onceMinimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-router-basic-example-wdvkbt?file=app/app.routing.module.ts
As You can see, on each navigation
UrlMatcheris called twice. What's even weirder is thatgroupargument is different each time - one hasparentand one doesn't.What is the motivation / use case for changing the behavior?
Originally I wanted to create matcher that would match route only if You are in specific named outlet:
So I could use one lazy-loaded module to define routes for many named outlets, example:
But because of router's weird behavior this doesn't work.
Environment