The initially loading (of an existing iu.unit
) fails:
<select id="unit" name="unit" #unit="ngModel" class="form-control"
[(ngModel)]="iu.unit" (change)="onDropdownChangeUnit(rec,iu)">
<option *ngFor="let i of UI_Units" [ngValue]="i">{{i.name}}</option>
</select>
It shows me all unit
's from UI_Units
, but it doesn't show the initial value of iu.unit
.
What did I d wrong ?
Updated
Structure, I go with a foreach
over all ingridientUnit => iu
, try to assign it with it's initial value.
But when the user wants to change that - UI_Units => coming from backend(asp.net Core)
- it should be reassigned to iu.unit
.
export class Recipe{
id: string;
ingridientUnit: IngridientUnit[] // iu
// ...
}
export class IngridientUnit {
id: string;
unit: Unit[]
// ...
}
export class Unit {
id: string;
name: string;
// ...
}
Fetching from server:
getUnits(filter: ServerRequest) {
return this._http.get(this.myAppUrl + 'Unit/GetUnits' + '?' + this.toQueryString(filter))
.pipe(map((res: Unit[]) => { return res; }));
}