我想找到Angular 2內聯編輯的示例或指針。我在Angular 1中找到了一些非常好的示例,例如Inline edit demo (angular 1.0)。但是我正在努力尋找類似於Angular 2的示例。我基本上需要達到類似於此示例中的結果。當談到Angular 2(1或2)時,我是一個完全新手,所以任何幫助都非常感激。* ngFor循環內的Angular 2內聯編輯
我已經包括了我的Html,並且這個想法是,當按鈕被點擊時,userEditing標誌被設置爲true,但我只希望選擇的行改變爲Input元素而不是當前正在發生的所有行ngfor
<tr *ngFor='let user of userList'>
<td>
<input type="checkbox" [(ngModel)]="user.state">
</td>
<td>
{{user.userId}}
</td>
<td>
<input id="userName" type="text" class="form-control" ng-model="user.userName" *ngIf="userEditing" />
<span *ngIf="!userEditing"> {{user.userName}}</span>
</td>
<td>
<input type="text" class="form-control" ng-model="user.firstName" *ngIf="userEditing" />
<span *ngIf="!userEditing"> {{user.firstName}}</span>
</td>
<td>
<input type="text" class="form-control" ng-model="user.lastName" *ngIf="userEditing" />
<span *ngIf="!userEditing"> {{user.lastName}}</span>
</td>
<td>
<input type="text" class="form-control" ng-model="user.department" *ngIf="userEditing" />
<span *ngIf="!userEditing"> {{user.department}}</span>
</td>
<td> <button type="button" [ngClass]="{disabled : !enableButton}" class="btn btn-default" (click)="getUserToEdit($event, user.userId)">{{editUserButtonCaption}}</button>
<td> <button type="button" class="btn btn-default" (click)="deleteUser(user.userId)">{{deleteUserButtonCaption}}</button></tr>
<tr>
現在正在爲此解決此問題。 – Zze