Search code examples
angularrouter-outlet

Angular 6 - Passing a value from outlets to Component


I need to pass a value to the outlet route.

This is my html template:

<li class="list-group-item *ngFor="let item of items">
    <ul class="list-inline">
        <li class="list-inline-item">
            <a [routerLink]="['/dashboard/', {outlets: {'mainOutlet':'viewdetail/'}}]"><span> {{item.doc}} - {{item.customer}}</span></a>
        </li>
    </ul>
</li>

And I need to pass the value of item.id, I have tried different ways and I do not get it, it would be something like that, but I do not get the value of item.id, I disregard the syntax of how could put it correctly.

<a [routerLink]="['/dashboard/', {outlets: {'mainOutlet':'viewdetail/item.id'}}]"><span> {{item.customer}}</span></a>

Thanks for the help,


Solution

  • I think you are setting 'item.id' as a string instead of the value

    <a [routerLink]="['/dashboard/', {outlets: {'mainOutlet':'viewdetail/' +item.id}}]"><span> {{item.customer}}</span></a>