Skip to content

Instantly share code, notes, and snippets.

@ihadeed
Last active August 8, 2017 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihadeed/bf7317a0545d026c12739b8a7eb3470a to your computer and use it in GitHub Desktop.
Save ihadeed/bf7317a0545d026c12739b8a7eb3470a to your computer and use it in GitHub Desktop.
angular2-text-mask with Ionic 2
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding class="home">
<ion-list>
<ion-item>
<ion-label>Something</ion-label>
<!-- ionic2 input -->
<ion-input [textMask]="maskOptions" type="text"></ion-input>
</ion-item>
<ion-item>
<!-- regular input -->
<input type="text" [textMask]="maskOptions" >
</ion-item>
</ion-list>
</ion-content>
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {Directive} from 'angular2-text-mask';
@Component({
templateUrl: 'build/pages/home/home.html',
directives: [Directive]
})
export class HomePage {
maskOptions: any = {
mask: [
'(',
/[0-9]/,
/[0-9]/,
/[0-9]/,
')'
]
};
constructor(private navCtrl: NavController) {
}
}
@talvane
Copy link

talvane commented Dec 29, 2016

The "decorator" "@component" does not exist to "directive" properties... Right?

@staskuban
Copy link

U should import 'MaskedInputDirective' and place it in declarations section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment