I'm trying to bind transcluded content to a variable inside of a component loop but I'm unable to do so.
I've looked at the PrimeNG's dropdown
component and they use the template
tag along with let-car
to bind to the car
variable of the loop.
However when I try this I can't even get the content to transclude. What is the correct way of achieving this?
Attempts:
<!-- Obviously not gonna work -->
<comp>
<span>{{option.name}}, {{option.type}}</span>
</comp>
<!-- Thought this would work but it doesn't, in odd scenarios I get the last element of the loop to transclude content and bind correctly. -->
<comp>
<template let-option>
<span>{{option.name}}, {{option.type}}</span>
</template>
</comp>
In component:
<ul>
<li *ngFor="let option of options">
<ng-content></ng-content>
</li>
</ul>
Simple plunkr of what I'm trying to achieve: