给定以下标记
<div *ngFor="let item of items">
<input type="text" #val />
</div>我在组件中定义了
@ViewChildren('val') rows;我禁用了第一个输入元素
this.rows.first.nativeElement.disabled = true;我如何循环来禁用所有的输入?
这不管用
this.rows.forEach(val => val.disabled = true);这也不管用
this.rows.forEach(val => val.nativeElement.disabled = true);发布于 2018-09-14 02:40:21
要循环遍历子程序,请使用toArray(),如下所示:
this.rows.toArray().forEach(val => val.nativeElement.disabled = true);https://stackoverflow.com/questions/52324250
复制相似问题