对于我的路由器,我有以下配置。次要路由器出口包含在主路由器中。当我尝试使用routerLink来显示roster.component.html时,它会抛出以下错误:我尝试了许多不同的配置,但我不明白为什么它不能工作。
错误错误:" object“resolvePromise http://localhost:4200/polyfills.js:3159:31 resolvePromise http://localhost:4200/polyfills.js:3116:17 scheduleResolveOrReject http://localhost:4200/polyfills.js:3218:17 invokeTask http://localhost:4200/polyfills.js:2766:17 onInvokeTask http://localhost:4200/vendor.js:73499:24 invokeTask http://localhost:4200/polyfills.js:2765:17 runTask http://localhost:4200/polyfills.js:2533:28 http://localhost:4200/polyfills.js:2533:28 drainMicroTaskQueue http://localhost:4200/polyfills.js:2940:25 invokeTask http://localhost:4200/polyfills.js:2845:21 http://localhost:4200/polyfills.js:3885:9 http://localhost:4200/polyfills.js:3911:17
app.module.ts
import { RouterModule, Routes } from '@angular/router';
const appRoutes: Routes = [
{path: '', component: ProfileComponent},
{path: 'roster', component: RosterComponent, outlet: 'basis'},
/*
{path: '', component: ProfileComponent,children: [
{path: 'roster', component: RosterComponent, outlet: 'basis'},
]}
*/
]
@NgModule({
declarations: [
AppComponent,
MainViewComponent,
ProfileComponent,
RosterComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
RouterModule.forRoot(appRoutes),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }main-view.component.html
<router-outlet></router-outlet>profile.component.html
<a [routerLink]="[{ outlets:{ primery:['],basis: ['roster'] } }]">GO</a>
<router-outlet name="basis"></router-outlet>发布于 2018-12-21 15:09:57
路由器配置:
{ path: '', component: ProfileComponent,
children: [
{ path: 'roster', component: RosterComponent, },
]
}app.component.html或main-view.component.html
<a routerLink="/roster">Go</a>profile.component.html
<router-outlet></router-outlet>https://stackoverflow.com/questions/53886353
复制相似问题