【发布时间】:2018-06-05 11:33:42
【问题描述】:
尝试使用*ngFor 对Object.entries 在我的标记中循环浏览JS 字典并收到错误消息:
解析器错误:[let [key, item] of Object.entries(items)] 中的第 5 列出现意外的标记 [、预期的标识符、关键字或字符串]
模板:
<button *ngFor="let [key, item] of Object.entries(items)"
(click)="itemClicked.emit([key, item.value])">
{{ item.displayName }}
</button>
打字稿:
export interface DropDownItem {
displayName: string,
value: any,
checked: boolean
}
@Component({ /* ... */ })
export class MyComponent {
@Input() items: { [key: string]: DropdownItem };
@Output() itemClicked = new EventEmitter<[string, any]>();
Object = Object;
constructor() { }
}
【问题讨论】:
-
Angular 模板解析器不是
标签: angular typescript