fix(router): disallow component routes with named outlets
Closes #11208, #11082
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
import {Type} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
import {PRIMARY_OUTLET} from './shared';
|
||||
|
||||
/**
|
||||
* @whatItDoes Represents router configuration.
|
||||
@ -320,6 +320,10 @@ function validateNode(route: Route): void {
|
||||
if (Array.isArray(route)) {
|
||||
throw new Error(`Invalid route configuration: Array cannot be specified`);
|
||||
}
|
||||
if (route.component === undefined && (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
|
||||
throw new Error(
|
||||
`Invalid route configuration of route '${route.path}': a componentless route cannot have a named outlet set`);
|
||||
}
|
||||
if (!!route.redirectTo && !!route.children) {
|
||||
throw new Error(
|
||||
`Invalid configuration of route '${route.path}': redirectTo and children cannot be used together`);
|
||||
|
@ -12,8 +12,6 @@ import {RouterOutletMap} from '../router_outlet_map';
|
||||
import {ActivatedRoute} from '../router_state';
|
||||
import {PRIMARY_OUTLET} from '../shared';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @whatItDoes Acts as a placeholder that Angular dynamically fills based on the current router
|
||||
* state.
|
||||
@ -79,6 +77,10 @@ export class RouterOutlet implements OnDestroy {
|
||||
activatedRoute: ActivatedRoute, loadedResolver: ComponentFactoryResolver,
|
||||
loadedInjector: Injector, providers: ResolvedReflectiveProvider[],
|
||||
outletMap: RouterOutletMap): void {
|
||||
if (this.isActivated) {
|
||||
throw new Error('Cannot activate an already activated outlet');
|
||||
}
|
||||
|
||||
this.outletMap = outletMap;
|
||||
this._activatedRoute = activatedRoute;
|
||||
|
||||
|
Reference in New Issue
Block a user