In a modal, I have two selects that are populated with data from two different object arrays:
<select class="browser-default" id="gebied"
[(ngModel)]="filteredGebied"
(ngModelChange)="onChange($event)">
<option *ngFor="let gebied of list1"
value="{{gebied.id}}">{{gebied.beschrijving}}</option>
</select>
<select class="browser-default" id="domein" [(ngModel)]="filteredDomein">
<option *ngFor="let domein of list2"
value="{{domein.id}}">{{domein.beschrijving}}</option>
</select>
My goal is to dynamically update the options in the second select based on the selection made in the first select.
onChange(list1Id){
...
this.list2 = ...
}
However, I am facing an issue where the options in the second select do not update as expected.
Sometimes, an error occurs stating:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngForOf:
How can I resolve this problem and make the necessary changes?