Angular directive for input text masking
npm install ngx-textmaskFirst, install using below command.
Note: The below method is for standalone components
``bash`
npm i ngx-textmask --save
Then, use it in your component:
`typescript
import { NgModule } from '@angular/core';
import { MaskedInputDirective } from 'ngx-textmask';
@Component({
selector: 'app',
imports: [
MaskedInputDirective
],
template:
``
})
export class AppComponent {
public myModel = ''
public mask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]
}