Last active
August 8, 2017 12:25
-
-
Save ihadeed/bf7317a0545d026c12739b8a7eb3470a to your computer and use it in GitHub Desktop.
angular2-text-mask with Ionic 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
} | |
} |
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
The "decorator" "@component" does not exist to "directive" properties... Right?