ng-select inside modal
See original GitHub issueNullInjectorError: No provider for InjectionToken ng-select-selection-model! when ng-select is in component opened in modal (eg. ngx-modal)
Component:
export class RegistrationTypeEditComponent implements OnInit, OnDestroy {
@ViewChild('registrationTypeForm', {static: true}) public form: NgForm;
public model: any = {};
constructor(
public bsModalRef: BsModalRef) {
}
ngOnInit(): void {
}
}
HTML:
<div app-page [width]="'fw-800'">
<form (ngSubmit)="onSubmit()" #registrationTypeForm="ngForm">
<div class="row">
<div class="col-24 form-group">
<label for="type">{{'lbl.Type' | translate}}</label>
<ng-select
id="type"
name="type"
[items]="(enums$ | async)?.ERegistrationTypes"
[hideSelected]="true"
bindLabel="label"
bindValue="name"
[(ngModel)]="model.type"
required
>
</ng-select>
</div>
</div>
<button type="button" class="btn btn-light" (click)="onCancel()">{{'lbl.Cancel' | translate}}</button>
<button type="submit" class="btn btn-success float-right" [disabled]="!registrationTypeForm.form.valid">{{'lbl.Submit' | translate}}</button>
</form>
</div>
Calling function:
add(): boolean {
const modalOptions = {
myInterval: 0,
noWrapSlides: false,
initialState: {
model: {},
}
};
this.bsModalRef = this.bsModalService.show(RegistrationTypeEditComponent, modalOptions);
return false;
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Ng-select inside dialog add extra hidden height - Stack Overflow
I have a ng-select element inside a component that sits inside a mat-expansion-panel , and the contents at the bottom would get cut...
Read more >Ng-select inside dialog add extra hidden height (dropdown)
It works fine in bootstrap 4 modal window, but I will have a look that is wrong here. For now quick fix would...
Read more >Select component inside modal - Material Design for Bootstrap
I want to use the new select component inside a modal. The dropdown is not working like accepted. Generally it's there and I...
Read more >@ng-select/ng-select - npm
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@varnastadeus hi, i noticed you closed the issue, but still, seems the only way to fix this is to include NgSelectModuel in AppModule, is this correct? if that so seems not a right solution, appreciate if you give us some feedback about this. thanks!
Got it working, Including NgSelectModule in AppModule solves the issue as NgSelectModule is now not lazy loaded.