我有这段丑陋的代码:
<ng-container [ngSwitch]="filter.kind">
<p-select *ngSwitchCase="filterType.SelectboxFilter" [settings]="filter" > </p-select>
<p-autocomplete *ngSwitchCase="filterType.AutocompleteFilter" [settings]="filter" > </p-autocomplete>
<p-dropdown *ngSwitchCase="filterType.DropdownFilter" [settings]="filter"> </p-dropdown>
<p-special-autocomplete-filter *ngSwitchCase="filterType.SpecialFilter" [settings]="filter"> </p-special-autocomplete-filter>
<p-quantity-filter *ngSwitchCase="filterType.QuantityFilter" [settings]="filter"> </p-quantity-filter>
</ng-container>
例如,我正在寻找另一种方法来做-每个过滤器将在此处保存组件。
有可能吗?也许是另一种方式?
答案 0 :(得分:0)
您可以改用dynamic-component-loader-“ ComponentFactoryResolver” angular docs-但实施起来并不容易