Angular - issue looping with an ng-container

Viewed 7174

I want to call an ng-template from within a ngFor using an ng-container

My list is an array and has a list of objects. one property of an object is title - seen in the ng-template.

Html:

<ul>

    <li *ngFor='let item of list;let i = index'>

        <ng-container *ngTemplateOutlet="itemTemplate;context:item"></ng-container>

    </li>

</ul>

<ng-template #itemTemplate let-item="item">
    <p>{{ item?.title }}</p>
</ng-template>

Note: Issue is the let-item seems to be undefined or an empty object. which is strange since im passing it in.

3 Answers
Related