我在使用itemRendere和材料芯片时遇到了问题。我所拥有的是
<material-chips >
<material-chip *ngFor="let chip of data"
[value]="chip"
[removable]="true"
[selectionModel]="dataSelectionModel"
[itemRenderer]="dataOptionRenderer"
>
</material-chip>
</material-chips>哪里
final SelectionModel<MyType> datasetSelectModel = SelectionModel<MyType>.multi();
List<MyType> get data=>dataSelectionModel.selectedValues.toList();
ItemRenderer<MyType> dataOptionRenderer= ...所以就类型安全而言,一切都很好--选择模型和渲染器的泛型类型是完全相同的。然而,这最终导致了一个错误
Expected a value of type '(dynamic) => String', but got one of type '(MyType) => String'请注意,直接在material-chips标签上使用selectionModel和渲染器会产生相同的结果-迫使我使用非类型化的项目渲染器(因为这两种情况都会发生)
在angular dart中如何处理这样的情况?
发布于 2020-08-22 01:00:54
您需要在组件上声明directiveTypes
@Component(
directiveTypes: [
Typed<MaterialChipsComponent<MyType>>()
],
)https://stackoverflow.com/questions/63463024
复制相似问题