feat(router): better warning message when a router outlet has not been instantiated (#30246)
It is confusing when routes are successfully activated but a component is not present on a page, with this message it's more clear. PR Close #30246
This commit is contained in:
parent
763023472b
commit
1609815743
|
@ -6,6 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {isDevMode} from '@angular/core';
|
||||||
import {MonoTypeOperatorFunction} from 'rxjs';
|
import {MonoTypeOperatorFunction} from 'rxjs';
|
||||||
import {map} from 'rxjs/operators';
|
import {map} from 'rxjs/operators';
|
||||||
|
|
||||||
|
@ -185,6 +186,10 @@ export class ActivateRoutes {
|
||||||
// Activate the outlet when it has already been instantiated
|
// Activate the outlet when it has already been instantiated
|
||||||
// Otherwise it will get activated from its `ngOnInit` when instantiated
|
// Otherwise it will get activated from its `ngOnInit` when instantiated
|
||||||
context.outlet.activateWith(future, cmpFactoryResolver);
|
context.outlet.activateWith(future, cmpFactoryResolver);
|
||||||
|
} else if (isDevMode() && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
`A router outlet has not been instantiated during routes activation. URL Segment: '${
|
||||||
|
future.snapshot._urlSegment}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activateChildRoutes(futureNode, null, context.children);
|
this.activateChildRoutes(futureNode, null, context.children);
|
||||||
|
|
Loading…
Reference in New Issue