I have integrated the angular-code-input library into my project. However, upon loading a component that uses the Angular Code Input Component, I encountered an error message:
- Changes detected. Rebuilding...
ERROR ReferenceError: document is not defined
at _CodeInputComponent.focusOnInputAfterAppearing (c:/Users/X/Documents/sourcecode/web/node_modules/angular-code-input/fesm2022/angular-code-input.mjs:300:52)
at _CodeInputComponent.ngAfterViewChecked (c:/Users/X/Documents/sourcecode/web/node_modules/angular-code-input/fesm2022/angular-code-input.mjs:103:10)
...
Details:
The error seems to be originating from the use of the document object in the Angular Code Input Component, which may not be available when navigating to certain routes.
Steps to Reproduce:
- Initiate the Angular project.
- Go to the route with the component utilizing the Angular Code Input Component. The component loads, but errors are displayed in the terminal.
Expected Behavior: The component should load without errors after navigation to its route.
Environment:
- Angular version: 17.1.0
- Operating System: Windows
- Node.js version: v18.19.1
- npm: 10.2.4