1
<select ng-model="field.value" class="form-control" ng-attr-name="{{name}}">
            <option selected="selected">{{field.fieldName}}</option>
            <option ng-repeat="app in field.attributes.split(',')" value="{{app}}">{{app}}</option>
</select>

In this code, my expected behaviour is , it will show the select box and it select the first option I have added selected="selected".

but it not selecting that "selected" attribute element.

I have tried this with ng-selected="true" also. It also not help for me. any suggestion for me?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
vimal prakash
  • 1,503
  • 1
  • 22
  • 38

1 Answers1

4

You should be using the ngOptions directive - not a ngRepeat on an option element:

<select ng-model="field.value" ng-options="app as app for app in field.attributes.split(',')" class="form-control" ng-attr-name="{{name}}"></select>

Now simply set your ngModel (field.value) to the field you want selected.

tymeJV
  • 103,943
  • 14
  • 161
  • 157