default selected options for multiselect having ng-option in angularjs

28 views Asked by At
<select ng-if="field.Type == 'multi-select'" name="SpecialFields_{{::field.FieldID}}" id="SpecialFields_{{::field.FieldID}}" ng-model="vmpUserObj.specialfields[field.FieldID]" class="form-control" ng-options="item.OptionID as item.OptionLabel for item in ::field.FieldOptions track by item.OptionID" multiple>
</select>

How can i make multiple options selected in this select field . the ng-model will be ["177", "178", "176"]

1

There are 1 answers

0
rahul On

I got it, it was my silly mistake. Here each element in the array is a string rather than a number. so i converted the elements to integer and it worked perfectly (converted using stringarray.map(Number);)