Hy, don't be embarrassed by this. Select is one very irritating thing in
angularjs. Try this one, it worked for me
Only thing here a had to set "options" as array with objects with propertis
name, value and selected
var options = [{name:"name1", value="value1", selected=false},
{name:"name2", value="value2", selected=true},
{name:"name3", value="value3", selected=false},]
<select class="form-control" ng-model="modelName">
<option ng-repeat="option in options"
value={{option.value}}
data-ng-selected="{{option.selected}}">{{option.name}}</option>
</select>
On Monday, November 12, 2012 6:51:25 PM UTC+1, ehahn wrote:
>
> I'm embarrassed to say I'm having trouble getting my <options value=xxx>
> to be set correctly when binding to an array, e.g (trivial, contrived
> example) to have the value match the label:
>
> <select ng-model="result" ng-options="value as value for value in [123,
> 456]"></select>
>
> I'd like to see:
>
> <option value="123">123</option>
>
> but I always see:
>
> <option value="-index-">123</option>
>
> Here's the plunk: http://plnkr.co/edit/oyEdHG?p=preview
>
> BTW, works fine for object binding, just not array binding. Thanks.
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.