In this demonstration, only the unit
-object will be saved:
<select id="unit" name="unit" #unit="ngModel" class="form-control" [(ngModel)]="iu.unit" (change)="onDropdownChangeUnit($event)">
<option *ngFor="let i of UI_Units" [ngValue]="i">{{i.name}}</option>
</select>
The final object structure can be viewed here.
The goal is to update both the unit
-object and the unitID
within the object during each iteration in the foreach
-loop, including loading the initial value from its corresponding unitID
.
Any suggestions on how to achieve this?
Update:
The object is fetched from the backend without the unit
, but with the presence of unitId
. The missing data like unit
can be populated using UI_Units
.
A) Need the ability to preselect the initial value based on iu.unitId
=> i
(unit
) (if possible)
B) Upon selecting a different i
(unit
), both iu.unitId
and iu.unit
should get updated accordingly.
Hopefully, this clarifies things further.