Ionic3 - Can't bind to 'textMask' since it isn't a known property of 'ion-input'

10,824

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

Share:
10,824

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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/],
        };
     }
    }
    
  • Admin
    Admin almost 6 years
    I imported TextMaskModule in the contact-page.module.ts and it works fine. Thanks for your help.