Reputation: 123
My purpose is to use this select
in my lazy load module I do:
imports: [
CommonModule,
FormsModule,
NgSelectModule
],
providers: []
The template:
<ng-select [items]="list" [bindLabel]="TIPE" bindValue="id" [(ngModel)]="tipe" (onChange)="changeValue($event)" >
</ng-select>
When the user goes on this route, it prints in the console this error:
:
Uncaught (in promise): 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!
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!
I don't understand why,anyone can help me?
Upvotes: 5
Views: 6159
Reputation: 63
Only add NgSelectModule
to app.module.ts
and it works all across your app. This module doesn't work properly in a modal for example, because of it lazy loading.
Upvotes: 0
Reputation: 671
Do import NgSelectModule
in your app.module.ts
along with the component module.
Upvotes: 2
Reputation: 1219
I faced similar issue while running test case.
I resolved it by importing NgSelectModule
under imports
block.
If you are using NgSelectComponent
in your code for some use-case/scenario purpose then you can also declare NgSelectComponent
under declarations
block if needed
TestBed.configureTestingModule({
imports: [... , NgSelectModule],
declarations: [MultiSelectCtrlComponent, NgSelectComponent],
providers: []
});
I hope it may help you or someone else!
Upvotes: 0
Reputation: 635
We had a different problem. We used @ng-select/ng-select": "3.7.2" and one of the third party component used the version 3.7.3.
After we updated to the same version the problem disappeared.
Upvotes: 1