2015-12-02 71 views
0

我正在使用bootstrap-multiselect进行多选下拉菜单。我的继承人码 -Boostrap多选下拉菜单空

<td style="padding-left: 20px;"> 
    <select ng-model="$parent.selectedRunningInstances" id="multiSelectDropDown" multiple="multiple"> 
     <option ng-repeat="instance in instances" value="{{instance.name}}" >{{instance.name}}</option> 
    </select> 
</td> 

但是,即使我有实例阵列,以在它的对象,它显示空的下拉列表

生成的HTML -

<td> 
    <select ng-model="$parent.selectedRunningInstances" id="multiSelectDropDown" multiple="multiple" class="ng-pristine ng-valid" disabled="" style="display: none;"> 
    <!-- ngRepeat: instance in instances --> 
    <option ng-repeat="instance in instances" value="CacheServer" class="ng-scope ng-binding">CacheServer</option> <!-- end ngRepeat: instance in instances --> 
    <option ng-repeat="instance in instances" value="Instance1" class="ng-scope ng-binding">Instance1</option><!-- end ngRepeat: instance in instances --> 
</select> 

<div class="btn-group"><button type="button" class="multiselect dropdown-toggle btn btn-default disabled" data-toggle="dropdown" title="None selected" disabled=""><span class="multiselect-selected-text">No Instances</span> <b class="caret"></b></button><ul class="multiselect-container dropdown-menu"></ul> </div> 
</td> 

回答

0

我面临这个问题已经。尝试使用jQuery

$scope.instances.forEach(function(instance){ $('#multiSelectDropDown').append('<option>'+instance.name+'</option>') })

干杯的帮助附加选项。

+0

但是,为什么它不正常工作。 – Disha

+0

这不适用于我 – Disha

0

demo

(function(angular) { 
 
    'use strict'; 
 
angular.module('ngrepeatSelect', []) 
 
    .controller('ExampleController', ['$scope', function($scope) { 
 
    $scope.data = { 
 
    repeatSelect: null, 
 
    availableOptions: [ 
 
     {id: '1', name: 'Option A'}, 
 
     {id: '2', name: 'Option B'}, 
 
     {id: '3', name: 'Option C'} 
 
    ], 
 
    }; 
 
}]); 
 
})(window.angular);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="UTF-8"> 
 
    <title>Example - example-ngrepeat-select-production</title> 
 
    
 

 
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script> 
 
    <script src="app.js"></script> 
 
    
 

 
    
 
</head> 
 
<body ng-app="ngrepeatSelect"> 
 
    <div ng-controller="ExampleController"> 
 
    <form name="myForm"> 
 
    <label for="repeatSelect"> Repeat select: </label> 
 
    <select name="repeatSelect" id="repeatSelect" ng-model="data.repeatSelect" multiple> 
 
     <option ng-repeat="option in data.availableOptions" value="{{option.id}}">{{option.name}}</option> 
 
    </select> 
 
    </form> 
 
    <hr> 
 
    <tt>repeatSelect = {{data.repeatSelect}}</tt><br/> 
 
</div> 
 
</body> 
 
</html>

+0

我想使用引导多选 – Disha