Skip to content

laijuthomas/ngx-textmask

Repository files navigation

Angular Input Mask

Getting started

First, install it.

npm i ngx-textmask --save

Then, import it into your @NgModule:

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { TextMaskModule } from 'ngx-textmask';

@NgModule({
  imports: [
    FormsModule,
    TextMaskModule
  ],
  declarations: []
})
export class MyModule {}

Then, use it in your component:

@Component({
  selector: 'app',
  template: `
    <input [textMask]="{mask: mask}" [(ngModel)]="myModel" type="text"/>
  `
})
export class AppComponent {
  public myModel = ''
  public mask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]
}

About

Masking library to mask phone, date, currency etc

Resources

License

Stars

Watchers

Forks

Packages

No packages published