【发布时间】:2018-12-21 14:22:49
【问题描述】:
我的路由器插座具有以下配置。辅助路由器插座包含在主要路由器插座中。当我尝试使用 routerLink 显示 roster.component.html 时,它会引发以下错误。我尝试了许多不同的配置,但我不明白为什么它不起作用。
错误错误:“[object Object]”resolvePromise http://localhost:4200/polyfills.js:3159:31resolvePromise http://localhost:4200/polyfills.js:3116:17 scheduleResolveOrReject http://localhost:4200/polyfills.js:3218:17invokeTask http://localhost:4200/polyfills.js:2766:17onInvokeTask http://localhost:4200/vendor.js:73499:24invokeTask http://localhost:4200/polyfills.js:2765:17runTask http://localhost:4200/polyfills.js:2533:28drainMicroTaskQueue http://localhost:4200/polyfills.js:2940:25invokeTask http://localhost:4200/polyfills.js:2845:21invokeTask http://localhost:4200/polyfills.js:3885:9globalZoneAwareCallback http://localhost:4200/polyfills.js:3911:17core.js:12501
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>
【问题讨论】:
标签: angular router-outlet