我在模态boopstrap中使用select 4.0.0,我没有加载我选择的数据。我的代码:
<select style="width:100%" class="configServices" multiple="true" ng-model="widget.configuration.services">
<optgroup ng-repeat="service in services" ng-if="service.children" label="{{service.service_name}}">
<option ng-repeat="children in service.children" value="{{children.service_code}}">{{children.service_name}}</option>
</optgroup>>
<option ng-repeat="service in services" ng-if="!service.children" value="{{service.service_code}}">{{service.service_name}}</option>
我的angularJS:
$scope.services = []
$scope.images = []
$scope.stringVal = []
Services.status2 (services) ->
services.data.forEach (service) ->
$scope.services.push service
if service.children
service.children.forEach (children) ->
$scope.images[children.service_name] = children.service_icon
else $scope.images[service.service_name] = service.service_icon
formatService = (service) ->
return $('<img style="height: 20px; width: 20px; border-radius:19px;" src="' +$scope.images[service.text]+ '" /><b>'+' '+service.text+'</b>')
$(".configServices").select2({
maximumSelectionLength: 15,
templateResult: formatService,
templateSelection: formatService
});
如何初始化运行模式时保存的数据。