fix(router): should navigate to the same url when config changes
Closes #15535
This commit is contained in:
parent
ec89f378fc
commit
4340beacea
@ -313,7 +313,7 @@ export class Router {
|
|||||||
get events(): Observable<Event> { return this.routerEvents; }
|
get events(): Observable<Event> { return this.routerEvents; }
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
triggerEvent(e: Event) { this.routerEvents.next(e); }
|
triggerEvent(e: Event): void { this.routerEvents.next(e); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the configuration used for navigation and generating links.
|
* Resets the configuration used for navigation and generating links.
|
||||||
@ -332,10 +332,11 @@ export class Router {
|
|||||||
resetConfig(config: Routes): void {
|
resetConfig(config: Routes): void {
|
||||||
validateConfig(config);
|
validateConfig(config);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.navigated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @docsNotRequired */
|
/** @docsNotRequired */
|
||||||
ngOnDestroy() { this.dispose(); }
|
ngOnDestroy(): void { this.dispose(); }
|
||||||
|
|
||||||
/** Disposes of the router */
|
/** Disposes of the router */
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
|
@ -398,6 +398,25 @@ describe('Integration', () => {
|
|||||||
expect(location.path()).toEqual('/team/22/user/victor');
|
expect(location.path()).toEqual('/team/22/user/victor');
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
it('should navigate to the same url when config changes',
|
||||||
|
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
||||||
|
const fixture = createRoot(router, RootCmp);
|
||||||
|
|
||||||
|
router.resetConfig([{path: 'a', component: SimpleCmp}]);
|
||||||
|
|
||||||
|
router.navigate(['/a']);
|
||||||
|
advance(fixture);
|
||||||
|
expect(location.path()).toEqual('/a');
|
||||||
|
expect(fixture.nativeElement).toHaveText('simple');
|
||||||
|
|
||||||
|
router.resetConfig([{path: 'a', component: RouteCmp}]);
|
||||||
|
|
||||||
|
router.navigate(['/a']);
|
||||||
|
advance(fixture);
|
||||||
|
expect(location.path()).toEqual('/a');
|
||||||
|
expect(fixture.nativeElement).toHaveText('route');
|
||||||
|
})));
|
||||||
|
|
||||||
it('should navigate when locations changes',
|
it('should navigate when locations changes',
|
||||||
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
||||||
const fixture = createRoot(router, RootCmp);
|
const fixture = createRoot(router, RootCmp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user