Search code examples
javascriptangularrouter-outlet

Angular named router outlet link does not


While using router outlets in Angular I'm facing some problems.

I want to have a link like "maintopic/subtopicHeadline/subtopic", where I set the routes like this:

export const routes: Routes = [
  { path: 'home', component: AppComponent },

  {
    path: ':maintopic',
    component: SidenavMainComponent
  },
 
  {
    path: ':subtopicHeadline/:subtopic',
    component: ContentHandlerComponent,
    outlet: 'content'
  },
];

I get the values for the subtopicheadline and the subtopic correctly, but I don't know how to set the link for the router outlet. For now it is [routerLink]="['',{outlets:{content:[subtopic]}}]" but there I only get a link like "/subtopic". How must the link be written to reach the desired format?


Solution

  • Follow these videos - it is quite easy to Google it: