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

一个人想着一个人 提交于 2020-07-07 18:59:45

问题


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/],
    };
 }
}

回答1:


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



来源:https://stackoverflow.com/questions/50729114/ionic3-cant-bind-to-textmask-since-it-isnt-a-known-property-of-ion-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!