Shardul Pendse
Shardul Pendse

Reputation: 304

How we use ng-repeat on option tag

hello I am using the drop down option which are fetch from DB. and i made an array as below

var _arr = new Array()
_arr = [{className:5,avg:40},{className:6,avg:50},{className:7,avg:40}}]

in html inside the select tag

<option ng-repeat="flds in _arr" value="{{flds.className}}"></option>

here expected output will be option tag should have 3 elements. But i got 4 elements

Upvotes: 1

Views: 2147

Answers (1)

Alex
Alex

Reputation: 7919

Use the ng-options attribute on your <select> tag:

<select ng-options="flds.avg as flds.className for flds in _arr"></select>

More info

Upvotes: 1

Related Questions