ngx-currency
ngx-currency copied to clipboard
TypeError: Cannot read property 'createRange' of undefined
Hello,
I got this error when using ngx-currency with material input.
<input matInput type="number" placeholder="0" formControlName="buildingValue" required currencyMask >
TypeError: Cannot read property 'createRange' of undefined
at InputManager.get [as inputSelection] (input.manager.js:46)
at InputManager.get [as canInputMoreNumbers] (input.manager.js:27)
at InputService.get [as canInputMoreNumbers] (input.service.js:137)
at InputHandler.push../node_modules/ngx-currency/src/input.handler.js.InputHandler.handleKeypress (input.handler.js:82)
at CurrencyMaskDirective.push../node_modules/ngx-currency/src/currency-mask.directive.js.CurrencyMaskDirective.handleKeypress (currency-mask.directive.js:76)
Angular CLI: 7.3.9
Node: 10.16.0
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
I've got the same problem here:
<input type="number" currencyMask [(ngModel)]="model"/>
@Cerbrus the issue is with type="number"
. If you remove this then it works nicely. The error message should be different though, because it took me a while to find the cause.
Well that helps! It works like a charm now.
This should probably be documented somewhere.
Have the same error with ionic
ERROR TypeError: Cannot read property 'createRange' of undefined at InputManager.get inputSelection [as inputSelection] (ngx-currency.js:54) at InputService.get inputSelection [as inputSelection] (ngx-currency.js:356) at InputHandler.handleInput (ngx-currency.js:392) at CurrencyMaskDirective.handleInput (ngx-currency.js:550)
This would be nice to get fixed for the number input type, so we can use the accessibility features of the number input