angular - routerLink with outlet redirects to 404 error page -


i have angular 4 application , not able set working routerlink navigation. request gets redirected 404 error page.

here code:

the relevant part of route-config in ngmodule:

{    path: 'transactions',    component: transactionindexcomponent,    children: [       {          path: 'add',          outlet: "next",          component: transactionaddcomponent,          children: [             { path: "addperson", component: personsaddcomponent, outlet: "next" }          ]       },    ] }, 

the relevant part of transactionsindexcomponent template:

<a routerlink="[{ outlets: { next: 'add' } } ]" class="tile">add</a>  <router-outlet name="next"></router-outlet> 

the relevant part of transactionaddcomponent template:

<a routerlink="[{ outlets: { next: 'addperson' } } ]" class="tile">add person</a>  <router-outlet name="next"></router-outlet> 

i tried these values routerlink in transactionsindexcomponent:

  1. ['', { outlets: { next: 'add' } } ]
  2. [{ outlets: { next: 'add' } }]

none of them worked. what problem?

ps: templates self nested router-outlets working, because can open address /transactions/(next:add/(next:addperson)) without problems.

i found problem. missed square brackets in [routerlink]. works well:

<a [routerlink]="[{ outlets: { next: 'add' } } ]" class="tile">add</a>  <router-outlet name="next"></router-outlet> 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -