thelebdev / ng2-currency-mask

A very simple currency mask directive that allows using a number attribute with the ngModel.
MIT License
0 stars 3 forks source link

TypeError: Cannot read property 'apply' of undefined. #5

Open guillep2k opened 5 years ago

guillep2k commented 5 years ago

Migrated from original project (https://github.com/cesarrew/ng2-currency-mask/issues/125)

Orignal request by @Innomalist, @apappasadap

Hi, I have been using your component with angular 7.2 and it works fine except this error which seems to be a simple np error. If you could please include a fix on next release.

ERROR TypeError: Cannot read property 'apply' of undefined
    at CurrencyMaskDirective.push../node_modules/ng2-currency-mask/src/currency-mask.directive.js.CurrencyMaskDirective.handleBlur (currency-mask.directive.js:45)
    at Object.eval [as handleEvent] (xxxx.html:124)
    at handleEvent (core.js:21673)
    at callWithDebugContext (core.js:22767)
    at Object.debugHandleEvent [as handleEvent] (core.js:22470)
    at dispatchEvent (core.js:19122)
    at core.js:19569
    at HTMLInputElement.<anonymous> (platform-browser.js:993)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:16147)

Also by default even if no validation parameter is set it adds an ng-valid class to the input box which turns the placeholder to green color which isn't looking good to. If you could address this too please :)

tadeueliezer21 commented 4 years ago

Hello, @guillep2k! You can try this as fallows

first import ngModel in app.module.ts import { FormsModule } from '@angular/forms' after <input pInputText type="text" placeholder="0,00" name="valor" currencyMask [options]="{ prefix: 'R$ ', thousands: '.', decimal: ',', allowNegative: false }" ngModel>

guillep2k commented 4 years ago

Thank you, this should go to @Innomalist, @apappasadap (the original-original posters 😉)