Angular Ionic3-Can';t绑定到';文本掩码';因为它不是';t'的已知属性;离子输入';
我试图在离子3上使用textMask,但它不起作用 我收到错误消息(无法绑定到“textMask”,因为它不是“ion input”的已知属性)。我正在学习Joshmorony的教程Angular Ionic3-Can';t绑定到';文本掩码';因为它不是';t'的已知属性;离子输入';,angular,ionic-framework,ionic3,Angular,Ionic Framework,Ionic3,我试图在离子3上使用textMask,但它不起作用 我收到错误消息(无法绑定到“textMask”,因为它不是“ion input”的已知属性)。我正在学习Joshmorony的教程 app.module.ts 从“angular2文本掩码”导入{TextMaskModule}; @NGD模块({ 进口:[ FormsModule, textmask模块 ], contact.html contact.ts 从“angular2文本掩码”导入{TextMaskModule}; 导出类联系人页面
app.module.ts
从“angular2文本掩码”导入{TextMaskModule};
@NGD模块({
进口:[
FormsModule,
textmask模块
],
contact.html
contact.ts
从“angular2文本掩码”导入{TextMaskModule};
导出类联系人页面{
表格:表格组;
面具:任何;
电话号码:any=“”;
构造函数(){
此参数为0.1={
电话号码:['(',/[1-9]/,/\d/,/\d/,'),','',/\d/,/\d/,'-',/\d/,/\d/,/\d/],
};
}
}
如果您有现有的home.module.ts或联系人页面.module.ts(基于图像),请将TextMaskModule导入到他们,而不是在app.module.ts中导入。我在contact-page.module.ts中导入了TextMaskModule,效果很好。感谢您的帮助。
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/],
};
}
}