How to use mask on angular form initialisation?

534 Views Asked by At

I'm using Directive to handle input changes and apply a mask on the input value. But I can't apply the mask on the initial value on component init. Is there any way to apply the mask during form creation?

Code example:

export class VisitComponent implements OnInit {
    public form: FormGroup;
    constructor(private formBuilder: FormBuilder) {}

    ngOnInit() {
        this.form = this.formBuilder.group({
            name: ['', [Validators.required]],
            phone: ['9991234567'] // I want to format this value as (999) 123-45-67
        });
    }
}
0

There are 0 best solutions below