johan
johan

Reputation: 1012

Angular Select box returning Object

I have an Angular select dropdown that is populated from a constant. When updating the model the select doesn't update and: I am using track by ID but for some reason when an option is selected the whole object is returned instead of just the ID.

Could someone please have a look at this plunkr and let me know where I went wrong. https://plnkr.co/edit/UJMeR0gregFaavhT5wxs?p=preview

<select id="property_type_id" class="form-control"
    ng-model="proptype_id"
    ng-options="ptypes.Description for ptypes in proptypes track by ptypes.ID"
    >
<option value="">Please select Type</option>
                                                    </select>

Upvotes: 1

Views: 133

Answers (1)

Hadi
Hadi

Reputation: 17289

try this.

<select id="property_type_id" class="form-control"  
              ng-model="proptype_id"
              ng-options="ptypes.ID as ptypes.Description for ptypes in proptypes track by ptypes.ID">
     <option value="">Please select Type</option>
</select>

Upvotes: 1

Related Questions