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:
Dmitrij Kuba 2019-05-02 23:01:52 +03:00 committed by Andrew Kushnir
parent 763023472b
commit 1609815743
1 changed files with 5 additions and 0 deletions

View File

@ -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);