我正在尝试在子组件中使用辅助路由,类似于此处发布的问题.由于发布的"解决方案"更像是一种解决方法,我很好奇如何在上面的博文中做到这一点.
我在路由器3.1.2中使用Angular 2.1.2.
parent.module
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';
import { ParentComponent } from './parent.component';
import { ChildModule } from '../child/child.public.module';
import { ChildComponent } from '../child/child.public.component';
import { OtherModule } from '../other/other.public.module'
@NgModule({
imports: [
ChildModule,
OtherModule,
RouterModule.forRoot([
{ path: '', component: ChildComponent }
])
],
declarations: [ ParentComponent ],
bootstrap: [ ParentComponent ]
})
export class ParentModule { }
Run Code Online (Sandbox Code Playgroud)
parent.component
import …Run Code Online (Sandbox Code Playgroud)