Cannot find a differ supporting object ‘[object HTMLSelectElement]’ of type ‘object’.
NgFor only supports binding to Iterables such as Arrays.
ngFor指令只支持数组对象,而不支持Html的(Select类型)元素
因为
<select #week (change) = "selectChange('week',$event.target.value)">
<option *ngFor="let w of week" value={{w}}>
{{w}}
</option>
</select>
在select里面命名的#week 和 option里面循环的 let w of week 命名冲突了
ng2以为要循环select这个html元素

在使用Angular2开发过程中遇到错误:'Cannot find a differ supporting object ‘[object HTMLSelectElement]’ of type ‘object’. NgFor only supports binding to Iterables such as Arrays.'。该错误的根本原因是ngFor指令尝试绑定到一个HTMLSelectElement对象,而不是预期的数组。问题出在select元素内的#week变量名与option元素内let w of week的循环变量名冲突,导致Angular2误认为要遍历select元素本身。
633

被折叠的 条评论
为什么被折叠?



