我想用输入文本框替换标签,反之亦然,单击Angular 2中的按钮。我知道必须使用ngIf的某种类型,但我对如何执行有点困惑。Angular 2 - 单击以编辑表单域
HTML:
<form>
<div class="information">
<label *ngIf="editMode">{{textValue}}</label>
<input *ngIf="editMode" [ngModel]="name">
<button (click)="editMode=true">Edit</button>
<button (click)="editMode=false">Save</button>
</div>
</form>
这看起来不错,目前情况如何? –
替换为什么? –
我想要的是这个问题的答案。 http://stackoverflow.com/questions/37404746/replacing-label-with-input-textbox-and-vice-versa-by-clicking-a-button-in-angula 但是,这是角1,我使用角2和ng-show和ng-hide不是角2的一部分 – pPeter