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.

I get an error in Angular 4 when initialising autonumeric

See original GitHub issue

Expected behavior

<Please describe the expected behavior here> Install autonumeric using npm and import in code with import AutoNumeric from 'AutoNumeric' and instantiate autonumeric to work with input fields.

Actual behavior

I get an error: AutoNumeric_1.default is not a constructor

Steps to reproduce the problem

  1. Using autoNumeric <v4.0.1> and Chrome on both Mac and Windows,
  2. I used the options { currencySymbol: ‘$’ }, and
  3. Initialized my AutoNumeric object with the call new AutoNumeric(‘.autonumeric’, { currencySymbol: ‘$’ });,
  4. Got this error: AutoNumeric_1.default is not a constructor

Link to live example (ie. Codepen)

https://plnkr.co/edit/oublYED4HrXfyuzKNiNH?p=preview

Please help, I need this in my work. Cheers!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
fuyuko-akiyoshicommented, Jan 28, 2018

FYI in Angular 4 you need to import AutoNumeric like this: import * as AutoNumeric from ‘AutoNumeric’ otherwise it will throw an error. Cheers.

1reaction
fuyuko-akiyoshicommented, Jan 27, 2018

Of course, I hooked it into Angular’s OnInit life cycle event and it’s working now on the plunkr. I’m still unable to get it working on my local angular project though… it’s still giving me the same original error which must mean that angular is not recognising the autonumeric module. I’ll have to manually import it in somehow. Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

methods return '.autoNumeric is not a function - Can't unformat ...
Your error message indicates that autoNumeric() is not a jQuery method (which is true, it's not dependent on jQuery). You seem to have...
Read more >
autoNumeric/autoNumeric - Gitter
Hi there I have a best practice question regarding how to apply autonumeric on dynamically generated content in Angular 4. Currently all input...
Read more >
autoNumeric does not see value updates made via Vue #247
I'm having trouble making autoNumeric work well with Vue.js 2.0. ... I've used the autoNumeric plugin for years and have never had to...
Read more >
autonumeric - npm
autoNumeric is a standalone Javascript library that provides live *as-you-type* formatting for international numbers and currencies.
Read more >
autoNumeric - Decor Plan it
For your convenience I have created a HTML5 data and option code ... on getting autoNumeric() up and running with the initialize 'init' ......
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