I would like to display a collection of selectable objects in an angular 2 application (RC 5, forms 0.3.0)
<select [(ngModel)]="selectedItem">
<option *ngFor="let item of selectableItems"
[value]="item">
{{ item }}
</option>
</select>
<div> {{ selectedItem }} </div>
The list itself is correctly displayed.
But all that is displayed for 'selectedItem' is [object Object]. When accessing the item in code, I get the corresponding string "[object Object]". I tried switching to ngValue but that produces the same results.
The whole thing works when I use primitive values instead of objects. But I suspect that I am missing some crucial point here.
Thanks for your help. I've been wasting several hours on Internet search and trial and error. Maybe somebody has encountered the same problem.
Edit (24-08-16): I came across this tutorial which explains how to create common forms widgets today. Maybe it's useful for somebody who lands on this page: https://scotch.io/tutorials/how-to-deal-with-different-form-controls-in-angular-2