我正在使用bootstrap selectpicker,我无法设置要选择的值。我试着在他的数组值中设置模型名称,但它不能令人遗憾地工作。
<select
class="form-control"
name="groupCustomer"
title='Choose'
id="tags" multiple data-multiple-separator=" " data-max-options="3"
ng-model="moreDetailsData.groupCustomer">
<option ng-repeat="grp in groupCustomer" value="{{grp.id}}" data-content="<span class='label ' style='background:{{grp.group_color}}'>{{grp.group_name}}</span>">
</option>
</select>
致电功能:
<script type="text/javascript">
$(function() {
$('#tags').selectpicker('val','[1,2]');
});
</script>
角:
$scope.groupCustomer = [
{"id" : 1,"name" : "group 1"},
{ "id" : 2, "name" : "group 2"},
{"id" : 3,"name" : "group 3" },
{"id" : 4,"name" : "group 4" }]
$scope.moreDetailsData.groupCustomer = [1,2,3];
我该怎么做才能解决问题?
答案 0 :(得分:0)
试试这个:
$timeout(function () {
$('#tags').selectpicker();
$('#tags').selectpicker('val',$scope.moreDetailsData.groupCustomer).trigger("change");
});