代码:
<div class="row" *ngIf="goalStatusList;" >
<table class="table table-hover">
<thead>
<tr>
<td>Id</td>
<td>Name</td>
</tr>
</thead>
<tbody>
<tr *ngFor="let goalStatus of goalStatusList">
<th>{{goalStatus.goalStatusId}}</th>
<td><div *ngIf="!(goalStatus.editorEnabled)">
{{goalStatus.goalStatusName}}
<md-icon (click)="goalStatus.editorEnabled=true;">mode_edit</md-icon></div>
<div *ngIf="(goalStatus.editorEnabled)" ><md-input-container><input mdInput value="goalStatus.goalStatusName" #goalName></md-input-container><md-icon (click)="modifyGoal()" style="color:green;font:bold;" >done</md-icon><md-icon (click)="goalStatus.editorEnabled=false" style="color:red;font:bold;" >clear</md-icon></div></td>
</tr>
</tbody>
</table>
</div>
上面的mdInput字段不会打印goalStatusName值。相反,它只是打印goalStatus.goalStatusName
。
答案 0 :(得分:0)
这里有两个问题
你的ngIf应该没有括号,
<td><div *ngIf="!goalStatus.editorEnabled">
并在值
的情况下使用表达式<input mdInput value="{{goalStatus.goalStatusName}}" #goalName>