Ionic3-无法绑定到"textMask",因为它不是"ion-input"的已知属性 [英] Ionic3 - Can't bind to 'textMask' since it isn't a known property of 'ion-input'

查看:67
本文介绍了Ionic3-无法绑定到"textMask",因为它不是"ion-input"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ionic 3上使用textMask,但无法正常工作 我收到错误消息(无法绑定到'textMask',因为它不是'ion-input'的已知属性).我正在关注Joshmorony的教程 https://www.joshmorony. com/improve-mobile-form-ux-with-input-masks/

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/

单击此处查看错误消息

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

推荐答案

(如果您已有现有的 home.module.ts contact-page.module.ts (基于在图片上),将TextMaskModule导入到它们中,而不是在app.module.ts中

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

这篇关于Ionic3-无法绑定到"textMask",因为它不是"ion-input"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆