question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: Cannot read property 'apply' of undefined and ERROR: this.onModelChange is not a function

See original GitHub issue

When I use the example:

<input
    currencyMask
    value="numberValue1"
    [options]="{ prefix: 'R$ ', thousands: '.', decimal: ',' }"
/>

I get the following error when I click on the input and then click somewhere else:

core.js:5828 ERROR TypeError: Cannot read property 'apply' of undefined
    at CurrencyMaskDirective.handleBlur (ngx-currency.js:437)
    at CurrencyMaskDirective_blur_HostBindingHandler (ngx-currency.js:482)
    at executeListenerWithErrorHandling (core.js:21593)
    at wrapListenerIn_markDirtyAndPreventDefault (core.js:21635)
    at HTMLInputElement.<anonymous> (platform-browser.js:934)
    at ZoneDelegate.invokeTask (zone-evergreen.js:400)
    at Object.onInvokeTask (core.js:40744)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Zone.runTask (zone-evergreen.js:168)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:481)

And when I’m changing the values in the input I get the following error:

core.js:5828 ERROR TypeError: this.onModelChange is not a function
    at InputHandler.handleKeypress (ngx-currency.js:363)
    at CurrencyMaskDirective.handleKeypress (ngx-currency.js:456)
    at CurrencyMaskDirective_keypress_HostBindingHandler (ngx-currency.js:482)
    at executeListenerWithErrorHandling (core.js:21593)
    at wrapListenerIn_markDirtyAndPreventDefault (core.js:21635)
    at HTMLInputElement.<anonymous> (platform-browser.js:934)
    at ZoneDelegate.invokeTask (zone-evergreen.js:400)
    at Object.onInvokeTask (core.js:40744)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Zone.runTask (zone-evergreen.js:168)

The application is running on Angular 9

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:10

github_iconTop GitHub Comments

9reactions
tayambamwanzacommented, May 20, 2021

I’m not using ngModel, using reactive forms, any way around this?

1reaction
mkydouglascommented, Jan 6, 2021

Hey guys, let me share with you what I did… I just used the both attributes in the input: ngModel and ngModelChange. Like this:

<input currencyMask type="text" [(ngModel)]="valor" (ngModelChange)="teste()" [options]="{ align: 'left', prefix: 'R$ ', thousands: '.', decimal: ',', allowNegative: 'false', min: 0, max: 500000 }">

After this, the error message disappeared.

I hope it can help you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property '$apply' of undefined - Stack Overflow
I have research through the internet with this popular error and I have found no solution to my problem. What ...
Read more >
ng2-currency-mask - Bountysource
It works but I got this error message at the console. ERROR TypeError: Cannot read property 'setValue' of undefined at CurrencyMaskDirective.writeValue ( ...
Read more >
CANNOT READ PROPERTY 'APPLY' OF UNDEFINED
The message states that the button has no click-handler so it seems that the click handler (onResolvedOnlyClick) should be added not in the ......
Read more >
Uncaught TypeError: Cannot read property 'apply' of undefined
When trying to change theme component setting, clicking the green check button produces the following error, changes are not saved ...
Read more >
2013 - Uncaught TypeError: Cannot read property 'apply' of ...
I can see following issues in the code: In the line var listEnumerator = lists.getEnumerator();. the variable 'lists' is undefined, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found