Issue
I am trying to use textMask on ionic 3, but it's not working I am getting error message (Can't bind to 'textMask' since it isn't a known property of 'ion-input') . I am following Joshmorony's tutorial https://www.joshmorony.com/improve-mobile-form-ux-with-input-masks/
Click here to see the error message
app.module.ts
import { TextMaskModule } from 'angular2-text-mask';
@NgModule({
imports: [
FormsModule,
TextMaskModule
],
contact.html
<ion-input type="tel"
[(ngModel)]="phoneNumber"
[textMask]="{mask: masks.phoneNumber}" >
</ion-input>
contact.ts
import { TextMaskModule } from 'angular2-text-mask';
export class ContactPage {
form: FormGroup;
masks: any;
phoneNumber: any = "";
constructor() {
this.masks = {
phoneNumber: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
};
}
}
Solution
If you have existing home.module.ts or contact-page.module.ts (based on the image), do the importing of TextMaskModule to them and not in the app.module.ts
Answered By - Mystery
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.