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