rahul
rahul

Reputation: 23

default selected options for multiselect having ng-option in angularjs

<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"]

Upvotes: 0

Views: 25

Answers (1)

rahul
rahul

Reputation: 23

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);)

Upvotes: 0

Related Questions