angular-ngx-textmask
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Angular Input Mask

Just a port of the old angular2-text-mask to newer versions of angular.

Getting started

First, install it.

npm i angular-ngx-textmask --save

Then, import it into your @NgModule:

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { TextMaskModule } from 'angular-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/]
}

Package Sidebar

Install

npm i angular-ngx-textmask

Weekly Downloads

10

Version

1.0.4

License

MIT

Unpacked Size

244 kB

Total Files

22

Last publish

Collaborators

  • is0chronous