myComponent.html
-<my-component>
<ng-container *ngFor="let item of dataProvider">
<ng-template *ngTemplateOutlet="tmpContent; context: {$implicit: item, item: item}">
</ng-template>
</ng-container>
<ng-template #tmpContent let-item="item">
<div>
{{item.id}}
<ng-content></ng-content>
</div>
</ng-template>
用法:
<my-component dataProvider='source'>
<ion-label> test </ion-label>
</my-component>
它似乎迭代了正确的次数,但显示了<ion-label>
,这是内容在最后一次迭代中只投影了一次.那么,有没有可能每次都对这个ionic 标签进行内容投影.我需要用内容投影来实现,而不是ionic 标签可以是任何东西,所以将以声明的方式传递.