I have searched the internet, but I couldn't find an answer to my question.
What I am doing:
I have a ng-select that do infinite scrolling.
<ng-select [(ngModel)]="selected" id="studentsSelect" bindLabel="nameSelect" class="custom" (scrollToEnd)="fetchMore($event)">
<ng-option *ngFor="let student of infinite" [value]="student">{{student.name}}</ng-option>
</ng-select>
So the array infinite
gets populated when a user scroll to the bottom of the dropdown. When the page reloads it fetch from the students
array and insert into the infinite
array + 10 entries (if it can), so that it can select the saved option and be viewed in the dropdown list.
Also I save the state of the dropdown. So if you go to another location and back it will keep the selected option and repeat the top paragraph.
When the user returns to this page, the selected get set. But when you open the dropdown list, it doesn't scroll to the selected option. But if you close the dropdown and open it again without doing anything else, then it scrolled to it.
I'm not sure what is happening, or if there is something that I need to set.
Also no jquery may be used.