I am facing an issue with the ng-select
component in my Angular app.
When I bind an object to a formControlName
using Reactive Forms and set an initial value for the form control, the value is not displayed in the ng-select input field until I focus (click) on it.
Details:
- I am using an object for the bindValue property
- I have confirmed in the ngAfterViewInit hook that the selected value is correctly present in the form control and the objects in the items list and the form control value match perfectly
- However, the input field remains empty until I manually click on it
Calling focus
and then blur
methods in the ngAfterViewInit
hook does make it work, but I believe this is not the correct approach.
Is this an issue with how ng-select
handles initial object bindings? Am I missing something in the setup? How can I make it work the right way. Can someone help me to find the workaround of this issue?
Here is a StackBlitz link to reproduce the issue:
StackBlitz Demo