【发布时间】:2021-07-06 14:42:11
【问题描述】:
我正在尝试将数组显示为下拉菜单中的选项,但出现错误:
错误错误:找不到类型为“object”的不同支持对象“[object Object]”。 NgFor 只支持绑定到 Arrays 等 Iterables。
HTML 代码:
<mat-option *ngFor="let type of exportTemplates" value="{{ type.id }}">
{{ type.label }}
</mat-option>
TS 代码:
exportTemplates = [];
const subs = this.configService.state$.subscribe((config: any) => {
this.exportTemplates = config.templates.types;
});
this.subscription.push(subs);
【问题讨论】:
-
那不是数组。
标签: arrays angular typescript