首页 > 解决方案 > 掩码中的值不正确 Angular

问题描述

我有以下库 https://igorescobar.github.io/jQuery-Mask-Plugin/docs.html

我创建了这个指令

在此处输入图像描述

我的 TS

initForm() {
     this.form = this.fb.group({
           item_number: [this.service.lpu.item_number, Validators.required],
           material: [this.service.lpu.material, Validators.required],
           description: [this.service.lpu.description, Validators.required],
           unit: [this.service.lpu.unit, Validators.required],
           net_value: ['', Validators.required],
           gross_amount: ['', Validators.required],
           lpu_type: [this.service.lpu.lpu_type, Validators.required],
     });
}

和我的看法

<div fxFlex="35" fxFill fxLayoutAlign="start center">
       <mat-form-field>
           <mat-label>Valor Bruto</mat-label>
            <input matInput formControlName="gross_amount" money>
            </mat-form-field>
        </div>
        <div fxFlex></div>
        <div fxFlex="35" fxFill fxLayoutAlign="start center">
            <mat-form-field>
                <mat-label>Valor Líquido</mat-label>
                <input matInput formControlName="net_value" money>
            </mat-form-field>
    </div>

在控制台中我有这个结果 在此处输入图像描述

我不知道为什么结果是这样的“1,550”和“55,000”我需要结果来链接这个“15,00”和“550,00”任何想法?

标签: angularmask

解决方案


我认为口罩不能正常工作。库存储库中的示例可能会更好,它没有显示此特定掩码的预期结果。

mask("#.##0,00", {reverse: true}); // maybe wrong?!

你试过他的第一个金钱面具例子吗?

mask('000.000.000.000.000,00', {reverse: true});

我建议在掩码定义中尝试不同的模式,因为问题可能就在那里


推荐阅读