在2角我有这个component.html:角2 * ngIf为 '本'
<li *ngFor="let something of somethings">
<span>{{something}}</span>
<input class="doit" type="text" *ngIf="iscalled" />
<div id="container">
<button class="btn btn-warning editsection (click)="editAction()">Edit</button>
</div>
</li>
与此component.ts:
editAction(){ this.iscalled = true; }
是,默认情况下,在我的组件中设置为false。
基本上,对于每个something
的somethings
我产生,连同我的列表是分配给它的输入字段和运行editAction()
的按钮。只有当用户点击editAction()
按钮时,该按钮才会出现。
现在,照样,点击editAction()
按钮将启用列表中的所有输入字段。我想限制它的意思是确切的li
元素。
我不知道Angular 2是否有针对此问题的特定操作,或者这是否为纯javascript解决方案。
您是否考虑过使用ngFor公开的索引? – jonrsharpe