0

I have a map in angularJs which contain keys and values. I want to pass those keys and values to my dropdown in the HTML page. I am a newbie to angularjs.

Madhavee
  • 67
  • 8

1 Answers1

1

Try this:

<div ng-repeat="(key, value) in map">{{key}}: {{value}}</div>

//in your case

<select>
  <option value="val" ng-repeat="(key, val) in map" >{{ key }}</option>
</select>
Umesh
  • 941
  • 5
  • 12
  • {{key}}: {{value}} why you have used a div instead of a – Madhavee Apr 11 '19 at 00:44
  • It was just a use case for how to loop through map for any html tag. Below it I have mentioned how you can integrate it in the select dropdown. – Umesh Apr 11 '19 at 03:42
  • @Madhavee you may accept the answer if it helped: https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work cheers – Umesh Apr 11 '19 at 05:13
  • The given solution didn't work for me. I converted my map into an array.Then only it worked. – Madhavee Apr 11 '19 at 07:42