ngx-currency icon indicating copy to clipboard operation
ngx-currency copied to clipboard

TypeError: Cannot read property 'createRange' of undefined

Open dhermyt opened this issue 5 years ago • 5 comments

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

dhermyt avatar Aug 29 '19 14:08 dhermyt

I've got the same problem here:

<input type="number" currencyMask [(ngModel)]="model"/>

Cerbrus avatar Sep 13 '19 07:09 Cerbrus

@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.

dhermyt avatar Sep 13 '19 07:09 dhermyt

Well that helps! It works like a charm now.

This should probably be documented somewhere.

Cerbrus avatar Sep 13 '19 07:09 Cerbrus

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)

ozzpy avatar May 16 '20 14:05 ozzpy

This would be nice to get fixed for the number input type, so we can use the accessibility features of the number input

atomicrobokid avatar Jul 16 '21 09:07 atomicrobokid