select2 多选设置默认值
Select2 version 4.0.3 https://select2.github.io
<select id="slroles" ng-model="vm.usersetting.edt_roles" class="form-control select2" multiple="multiple"> </select>
function (response) { that.roles = response.data.DataSet.Body[0]; that.edt_roles = response.data.DataSet.Body[1]; $("#slroles").select2({ data: that.roles });
//主要写法 $('#slroles').val(that.edt_roles.split(',')); $('#slroles').trigger('change.select2'); $("#userEdit").modal("show"); }