دنبال کننده ها

۱۳۹۶ مهر ۱۱, سه‌شنبه

drop down menu - Angular 4 select entire object

[ad_1]



I have the following:



<select [(ngModel)]="selectedMetric">
<option *ngFor="let metric of suggestedMetrics" [value]="metric">metric.displayName</option>
</select>


Where suggestedMetrics is an array of objects (typescript class).



When I select an item from the list, the model gets updated with the string "[object Object]" instead of the object itself.



Does it only support strings? Can't I set it to an entire object? It would save me from finding it again in the original array...




[ad_2]

لینک منبع