Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'createRange' of undefined #54

Open
dhermyt opened this issue Aug 29, 2019 · 5 comments
Open

TypeError: Cannot read property 'createRange' of undefined #54

dhermyt opened this issue Aug 29, 2019 · 5 comments

Comments

@dhermyt
Copy link

dhermyt commented Aug 29, 2019

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
@Cerbrus
Copy link

Cerbrus commented Sep 13, 2019

I've got the same problem here:

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

@dhermyt
Copy link
Author

dhermyt commented Sep 13, 2019

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

@Cerbrus
Copy link

Cerbrus commented Sep 13, 2019

Well that helps! It works like a charm now.

This should probably be documented somewhere.

@ozzpy
Copy link

ozzpy commented May 16, 2020

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)

@atomicrobokid
Copy link

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

cmcnulty added a commit to cmcnulty/ngx-currency that referenced this issue Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants