angularjs - Setting default value in options angular -
i'm trying set default selected value in select
statement:
<p ng-repeat="something in somethings"> <select data-ng-options="key value (key , value) in values[$index]" ></select> </p>
my values
this:
[{1:2,2:3},{1:2,2:3},{1:2,2:3}]
note $index
outside iteration loop's index.
now imagine want select option 1
in 1st iteration of $index
, 2
in second iteration etc.
how achieve same?
you need ng-model angular attribute on select control set default item. exmaple:
<p ng-repeat="something in somethings"> <select ng-model="something.defaultvalue" data-ng-options="key value (key , value) in values[$index]" ></select> </p>
Comments
Post a Comment