文本蒙版不适用于角度2 [英] text-mask is not working for angular 2

查看:105
本文介绍了文本蒙版不适用于角度2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用

https://github.com/text-mask/text-mask/tree/master/addons#createnumbermask

  Uncaught Error: Template parse errors:
    Can't bind to 'textMask' since it isn't a known property of 'input'. ("lex="18" fxFlexOffset="1">


        <input [ERROR ->][textMask]="{mask: numberMask}" type="text" [(ngModel)]="myModel" ): 

我正在使用

"angular2-text-mask": "^8.0.4",
"text-mask-addons": "^3.7.1",
"text-mask-core": "^5.0.1",

已导入我的模块

imports: [
    BrowserModule,
    FormsModule,
    TextMaskModule
]

试图在我的组件中使用

numberMask = createNumberMask({
    prefix:'',
    suffix:'',
    allowDecimal: true
  })

我的html

<md-input-container fxFlex="18" fxFlexOffset="1">
        <span mdPrefix>{{currencySymbol}} &nbsp;</span>
        <input [textMask]="{mask: numberMask}" type="text" [(ngModel)]="myModel" mdInput >
        <md-error>This field is required</md-error>
      </md-input-container>

推荐答案

我必须在应用程序的主模块和特定模块中导入Modul

I had to import the Modul in the main Module as well as Specific Module of the application

imports: [
    BrowserModule,
    FormsModule,
    TextMaskModule
]

这篇关于文本蒙版不适用于角度2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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