розетка вторичного маршрутизатора внутри розетки основного маршрутизатора не работает

У меня следующая конфигурация розеток роутера. Вторичная розетка маршрутизатора находится в первичной. Когда я пытаюсь использовать 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 DrainMicroTaskQueue http://localhost:4200/polyfills.js:2940:25 invokeTask http://localhost:4200/polyfills.js:2845:21 invokeTask http://localhost:4200/polyfills.js:3885:9 globalZoneAwareCallback http://localhost:4200/polyfills.js:3911:17 core.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>

person Battalgazi    schedule 21.12.2018    source источник


Ответы (2)


Похоже, у вас есть опечатки, попробуйте следующее:

<a [routerLink]="[{ outlets: { primary: [''],basis: ['roster'] } }]">
    Go
</a>
person Narm    schedule 21.12.2018

Конфигурация роутера:

{ 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>
person Aragorn    schedule 21.12.2018