Ad

How To Display Data In Select Box Using AngularJS?

- 1 answer

Hi I want to bind the zipcode's in the select box from the following data. How to do that ??

[[{'zipcode':'6451105'},{'zipcode':'641515'},{'zipcode':'564555'}]]
Ad

Answer

Assuming you want to bind one of your zipcode objects to a property, eg

{zipcode: '641515'}

and your actual data looks like this

[{'zipcode':'6451105'},{'zipcode':'641515'},{'zipcode':'564555'}]

this should suffice

<select name="zipCode" ng-model="zipCode"
    ng-options="zipCode.zipcode for zipCode in zipCodes"></select>

http://plnkr.co/edit/rY0cFVqyZHVoB4DyZj1Z?p=preview

Ad
source: stackoverflow.com
Ad