Bootstrap multiselect下拉列表在具有ng-repeat的div中不起作用

时间:2015-12-18 06:21:20

标签: html angularjs angularjs-ng-repeat bootstrap-multiselect

我想使用bootstrap multiselect下拉列表为参数选择多个值。我正在使用它 -

<div ng-repeat="param in parameters">
  <div>{{param.name }} :</div>
  <div ng-show = "param.multipleValues">
    <select ng-model="param.value" id="testMultiSelect" multiple="multiple">
        <option ng-repeat="v in values" value="{{v}}" >{{v}}</option>
    </select>
  </div>
  <div ng-show = "!param.multipleValues">
    <input type="text" ng-model="param.value">
  </div>
</div>

但是,不知何故,多重选择在ng-repeat中不起作用。如果我把它放在这个有ng-repeat的div之外,它就可以了。 就像图像一样 - enter image description here

1 个答案:

答案 0 :(得分:1)

这可能有助于你

&#13;
&#13;
 
 var app = angular.module('testApp', [ ]);
 
 
 app.directive('telDropdownmutiple', ['$http', function ($http) {
	    return {
	        restrict: 'E',
	        scope: {
	            array: '=',
	            validate: '@',
	            ngModel: '=',
	            title: '@',
	            checkId: '@',
	            ngmaxLength: '@',
	            ngminLength: '@',
	            lblvalue: '@',
	            textboxSize: '@',
	            lblSize: '@',
	            ngShow: '@',
	            textboxtype: '@',
	            getString: '@',
	            multiple: '@',
	        }, 

	        template:'<div   id="{{ checkId }}"  > <span>{{ title }}</span>:<select  {{ multiple }}  class="{{className}}"  ng-model="ngModel" ng-options="a[optValue] as a[optDescription] for a in array"   requireiftrue="{{ validate }}"></div>'+
						'<option style="display: none" value="">{{title}}</option>' +
					'</select> </div>',
	        link: function (scope, element, attrs) {

	            scope.lblvalue = attrs.lblvalue;
	            scope.title = attrs.title;
	            scope.optValue = attrs.optValue;
	            scope.optDescription = attrs.optDescription;
	         
	        }
	    };
	}]);
	
	  app.controller('testController', ['$scope', '$location', function ($scope, $location) {
        
         $scope.SelectMultiple = [
			{Id: 1, Description: "option1"}, 
			{Id: 2, Description: "option2"}, 
			{Id: 3, Description: "option3"}, 
			{Id: 4, Description: "option4"},
			{Id: 5, Description: "option5"},
			{Id: 6, Description: "option6"}, 
			{Id: 7, Description: "option7"}, 
			{Id: 8, Description: "option8"}, 
			{Id: 9, Description: "option9"},
			{Id: 10, Description: "option10"}
		 ];
 
	  
      
  }]);
&#13;
<script data-require="angular.js@~1.3.15" data-semver="1.3.15" src="https://code.angularjs.org/1.3.15/angular.js"></script>
<body class="hold-transition skin-blue sidebar-mini" data-ng-app="testApp">
  
            <!-- Logo -->
    
        <!-- Left side column. contains the logo and sidebar -->
   

        <div class="content-wrapper" style=" margin-top: 50px; margin-bottom: 10px; height: 350px;   overflow-y: auto; " ng-controller="testController">
       <tel-Dropdownmutiple multiple ng-model="registration.multipledropGender"   lblvalue="Gender" array="SelectMultiple" opt-value="Id" opt-description="Description" validate='true' class-Name="form-controlselect select2" ></tel-Dropdownmutiple>
    </div>
 
 
 


</body>

 
&#13;
&#13;
&#13;