0
votes

I have the following configuration for my router outlets. The secondary router outlet is contained in the primary one. When I try to use routerLink to show the roster.component.html, it throws the following error.I tried many different configurations but I dont understand why it doesnt work.

ERROR Error: "[object 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>
2

2 Answers

1
votes

It looks like you have some typos, try this:

<a [routerLink]="[{ outlets: { primary: [''],basis: ['roster'] } }]">
    Go
</a>
0
votes

Router configuration:

{ path: '', component: ProfileComponent,
    children: [
      { path: 'roster', component: RosterComponent, },
    ]
  }

app.component.html or main-view.component.html

<a routerLink="/roster">Go</a>

profile.component.html

<router-outlet></router-outlet>