how to create a currency mask with regEx

0

Hello, I'm a beginner with angle 4, I'm trying to make a mask for a text field to validate a value in m².

The class Mask contains the method to create the mask, the value informed can be between 1 and unlimited.

I wanted the method to return something in this context: 1,000,000.00 or 10,000.00 or 1,000.00

export class Mask
{

  public static getArea():Array<string|RegExp>
    {

     return [/\d/,/\d/,/\d/,'.',/\d/,/\d/,/\d/,'.',/\d/,/\d/,/\d/,',',/\d/,/\d/];

    }
}
<input formControlName="areaImovel" [textMask]="{ mask: areaMask }" type="text" id="form-area-imovel" class="form-control">

Calling on the Component

import { Mask } from './mask';

export class EnderecoComponent implements OnInit {
  public areaMask = Mask.getArea();
  
  constructor(){}
}
    
asked by anonymous 22.01.2018 / 19:23

0 answers