question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Describe 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

  1. clone the example repo git clone https://github.com/boltex/ivy-lazyload-test
  2. run npm install to get all dependencies
  3. 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. image

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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:12

github_iconTop GitHub Comments

8reactions
Jelledbcommented, Jun 27, 2022

@github-actions that is fake news. It’s still an issue

5reactions
github-actions[bot]commented, Jun 15, 2022

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 🎆

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy-loading with Angular Ivy : No provider for ...
(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 ......
Read more >
No provider for InjectionToken ng-select-selection-model
When lazy-loading (with 'IVY') a module and component that uses ng-select, I get the error: "No provider for InjectionToken ...
Read more >
[Solved]-Lazy-loading with Angular Ivy : No provider for ...
Coding example for the question Lazy-loading with Angular Ivy : No provider for InjectionToken ng-select-selection-model-angular.js.
Read more >
ng-select/ng-select
Angular ng-select - All in One UI Select, Multiselect and Autocomplete. ... Start using @ng-select/ng-select in your project by running `npm ...
Read more >
NG0201: No provider for {token} found!
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found