不确定这是否重要,但我使用agGrid,但它基本上是创建一个动态组件作为参数。这可以作为我的网格选项:
... children: [ ... cellEditorFramework: SelectCellComponent, ... ] ...
但是如果我想做一个条件编辑器呢?像这样:
... children: [ ... cellEditorFramework: (params) => { return params.type === 'Select' ? SelectCellComponent : TextCellComponent }, ... ] ...
但这给了我一个错误:
找不到函数(params){的组件工厂。你加进去了吗
角度4.4.6 聚合17.1.1
可以创建包裹角组件
选择ExtWrapperComponent
... children: [ ... cellEditorFramework: SelectOrTextWrapperComponent, ... ] ...
并在运行时内部决定要显示的内容-选择或文本
<select-cell *ngIf="params.type == 'select'"></select-cell> <text-cell *ngIf="params.type != 'select'"></text-cell>