I get an error in Angular 4 when initialising autonumeric
See original GitHub issueExpected 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
- Using autoNumeric
<v4.0.1>
and Chrome on both Mac and Windows, - I used the options { currencySymbol: ‘$’ }, and
- Initialized my AutoNumeric object with the call new AutoNumeric(‘.autonumeric’, { currencySymbol: ‘$’ });,
- 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:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI in Angular 4 you need to import AutoNumeric like this: import * as AutoNumeric from ‘AutoNumeric’ otherwise it will throw an error. Cheers.
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!