text-mask is not working for angular 2

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 07:25:31

问题


Trying to use

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" ): 

I am using

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

Imported in my Module

imports: [
    BrowserModule,
    FormsModule,
    TextMaskModule
]

trying to use in my component

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

my 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>

回答1:


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

imports: [
    BrowserModule,
    FormsModule,
    TextMaskModule
]


来源:https://stackoverflow.com/questions/47188588/text-mask-is-not-working-for-angular-2

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