I am working on a dropdown
that populates with items of type ObjectA
.
item.component.html:
<label>items list:
<select formControlName="itemsCtl" (change)="onChange()">
<option *ngFor="let item of itemList" [value]="item">{{item.label}}</option>
</select>
</label>
When using reactive forms, I require the selected item. After researching extensively, I found suitable code for my requirement:
item.component.ts:
selectedItem : ObjectA;
...
onChange()
{
this.selectedItem = this.factorForm.controls['itemsCtl'].value;
}
However, upon retrieving the selected item, it is displayed as [object object]
instead of as ObjectA
. How can I ensure that the selected item is returned as ObjectA
, or how can I convert [object object]
to ObjectA
?
This project is built using Angular
version 5.0.1.