Pra*_*ghe 2 tags input angular
我在 Angular 6 项目中使用 ng2-currency-mask 模块,但是当在输入字段中应用(更改)方法时,它不起作用
这里我使用了输入标签
<input style="text-align:right; width:260px;" currencyMask [options]="{ prefix: 'Rs ', thousands: ',', decimal: '.' }" (change)="addToAllChange($event.target.value)" placeholder="Value" class="form-control"/>
Run Code Online (Sandbox Code Playgroud)
change即使因为指令,您也无法触发currencyMask。您可以利用ngModel和ngModelChange。
<input style="text-align:right; width:260px;" currencyMask
[options]="{ prefix: 'Rs ', thousands: ',', decimal: '.' }"
#currency
(ngModelChange)="addToAllChange(currency.value)"
[(ngModel)]="value"
placeholder="Value"
class="form-control"/>
Run Code Online (Sandbox Code Playgroud)
如果您想控制何时更新,可以使用ngModelOption.