From 1609815743323f17aa19309af32dd3af74bbfb17 Mon Sep 17 00:00:00 2001 From: Dmitrij Kuba Date: Thu, 2 May 2019 23:01:52 +0300 Subject: [PATCH] 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 --- packages/router/src/operators/activate_routes.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/router/src/operators/activate_routes.ts b/packages/router/src/operators/activate_routes.ts index a045bfe4a8..d946feaa7b 100644 --- a/packages/router/src/operators/activate_routes.ts +++ b/packages/router/src/operators/activate_routes.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +import {isDevMode} from '@angular/core'; import {MonoTypeOperatorFunction} from 'rxjs'; import {map} from 'rxjs/operators'; @@ -185,6 +186,10 @@ export class ActivateRoutes { // Activate the outlet when it has already been instantiated // Otherwise it will get activated from its `ngOnInit` when instantiated 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);