コンポーネントループ内の変数に継承されたコンテンツをバインドしようとしていますが、できません。角2は、継承されたコンテンツをループ変数にバインドします。
私はPrimeNGのdropdown
コンポーネントで見てきたし、彼らは、ループのcar
変数にバインドするlet-car
とともにtemplate
タグを使用します。
しかし、私がこれを試してみると、私はもはやtranscludeの内容を得ることができません。これを達成する正しい方法は何ですか?
試み:コンポーネントで
<!-- 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>
:
<ul>
<li *ngFor="let option of options">
<ng-content></ng-content>
</li>
</ul>
私が達成しようとしているかの簡単なplunkr:
https://plnkr.co/edit/6SS03fuXmbvJB4nmf1AO?p=preview
はコメントで完全な例を見つけ – SinistraD