货币类型的文本字段-一起使用formControlName和ngModelOption进行发布

时间:2018-12-04 11:20:55

标签: typescript angular6

嗨,我正在使用以下代码在发生模糊事件时将用户输入转换为货币格式:

 <input type="text"  placeholder="Test Price" [ngModel]="testPrice | currency:'USD':'symbol':'2.2'" [ngModelOptions]="{updateOn:'blur'standalone: true}" 
  (ngModelChange)="testPrice=$event"/>

以上这段代码对我来说很好用,但是只要我将formControlName包括为:

<input maxlength= 15 class="form-control" id="textid" formControlName="testInput" [ngModel]="testModel| currency:'USD':'symbol':'2.2' " (ngModelChange)="testModel=$event" [ngModelOptions]="{updateOn:'blur',standalone: true}"/>

它抛出以下错误

Can't bind to 'ngModelOptions' since it isn't a known property of 'input'. ("ol" id="FeePolicyAmt" formControlName="asdsd" [ngModel]="testPrice | currency:'USD':'symbol':'2.2'" [ERROR ->][ngModelOptions]="{updateOn:'blur',standalone: true}" 

我确保我已在module.ts中包含表单,并且formControlName也已正确定义

0 个答案:

没有答案