【发布时间】:2023-03-18 04:33:02
【问题描述】:
我在 html 中有一个输入字段,我想在对值执行一些工作后在输入内容后立即清除它。 我为此使用 ngModel。 问题是我的代码仅在我第一次在其中写入内容时才清除输入字段的值。之后就不行了。
receive.component.html
<mat-form-field class="example-full-width">
<input [(ngModel)]="donation_detail" (ngModelChange)="fecthDetail()"
matInput placeholder=" code">
</mat-form-field>
receive.component.ts
fecthDetail(){
console.log(this.donation_detail)
//do something with the vlaue and then clear it
this.donation_detail = '';
}
【问题讨论】:
标签: angular input ngmodel two-way-binding