When lazy-loading (with 'IVY') a module and component that uses ng-select, I get the error: "No provider for InjectionToken ng-select-selection-model"
See original GitHub issueDescribe the bug
I’m using angular’s new IVY compiler, along with the new lazy-loading functionality (Description and example here: https://www.debugbear.com/blog/lazy-loading-angular-components-without-a-router)
When lazy-loading a module and adding an instance of a component to my app, the ng-select does not appear in the component and I get this error in the console:
core.js:6354 ERROR NullInjectorError: R3InjectorError(AppModule)[InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model]: NullInjectorError: No provider for InjectionToken ng-select-selection-model! at NullInjector.get (http://localhost:4200/vendor.js:8736:27) at R3Injector.get (http://localhost:4200/vendor.js:24378:33) at R3Injector.get (http://localhost:4200/vendor.js:24378:33) at R3Injector.get (http://localhost:4200/vendor.js:24378:33) at NgModuleRef$1.get (http://localhost:4200/vendor.js:40184:33) at Object.get (http://localhost:4200/vendor.js:38095:35) at getOrCreateInjectable (http://localhost:4200/vendor.js:12876:39) at Module.ɵɵdirectiveInject (http://localhost:4200/vendor.js:28245:12) at NodeInjectorFactory.NgSelectComponent_Factory [as factory] (http://localhost:4200/lazy-lazy-module.js:4143:398) at getNodeInjectable (http://localhost:4200/vendor.js:13021:44)
Reproducible example see https://github.com/boltex/ivy-lazyload-test for a minimal repo exposing this bug.
To Reproduce
- clone the example repo
git clone https://github.com/boltex/ivy-lazyload-test
- run
npm install
to get all dependencies - run
ng serve
Expected behavior When trying this locally with ng serve, when the program loads in your browser, press the “Lazy load module & add instance of component below” button. (This will add some components instance into the app) The component should have an ng-select in it. It doesn’t and forementionned error appears in the console.
Note Ignore the first error in the console: Uncaught TypeError: ng.probe is not a function It is a normal error to get when using angular 9 because augury assumes angular dev mode is active if window.ng exists, but ivy doesn’t export probe right now.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [windows 10]
- Browser [chrome]
- Version [78.0.3904.108 (Official Build) (64-bit)]
Thanks for your time and attention to this issue !
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:12
Top GitHub Comments
@github-actions that is fake news. It’s still an issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions 🎆