0
私は、主要コンポーネントに格納されたコンポーネントの配列を持っています。彼らはさまざまな種類のものです。私はそれらをすべて表示するためにngForおよびngSwitchディレクティブを使用しました。他のコンポーネント内のコンポーネントテンプレート
<div *ngFor="let component of components"
[ngSwitch]="component.id">
<component-a *ngSwitchCase="1"></component-a>
<component-b *ngSwitchCase="2"></component-b>
<component-c *ngSwitchCase="3"></component-c>
</div>
このアプローチは、新しいタイプを追加するとかなり問題になります。 ComponentX、beacuse別のngSwitchケースを追加する必要があります。より一般的にする可能性はありますか?
可能なアプローチhttp://stackoverflow.com/questions/36325212/angular-2-dynamic-tabs-with-user-click-chosen-components/36325468#36325468 –