-6

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'}]]
3
  • I think the best way is using ng-options check the following link Commented Jan 12, 2016 at 1:21
  • 1
    You realise your data has multiple zipcode keys in the same object? Should it perhaps be [{'zipcode':'6451105'},{'zipcode':'641515'},{'zipcode':'564555'}] Commented Jan 12, 2016 at 1:26
  • Please read stackoverflow.com/help/how-to-ask Commented Jan 12, 2016 at 1:43

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Phill, Thank you for your reply ... i Want to display all the zipcodes in dropdown one by one .Still i din't get the solution.
@Gopinath I don't understand what you mean by "one by one"
Hi Phil I got the solution thank you very much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.