选择标签不支持多个



在我的代码中,我使用 ng-options 绑定数据来选择标签,并且我将 multiple 属性设置为 true。

<select ng-if="exp.metaData.elementType =='in'"
multiple=""
ng-multiple="true" 
class="form-control"
ng-model="exp.value"
ng-options="value.id as value.title for value in exp.dataSource">
   <option value=""> Select ...</option>
</select>

但是在浏览器运行时,select标签不支持多个,当我检查选择元素时也没有看到multiple="" or ng-multiple="true"。 (f12->元素)

下面是角度中多选的最小设置示例。不过,不确定为什么您需要多选Please select选项。

angular.module('test', []).controller('Test', Test);
function Test() {
  var vm = this;
  
  vm.options = [
    {name: 'aaa', value: '1'},
    {name: 'bbb', value: '2'},
    {name: 'ccc', value: '3'}
  ];
  
  vm.selected = [];
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app='test' ng-controller='Test as test'>
  <select multiple ng-options="option.value as option.name for option in test.options" ng-model="test.selected">
  </select>
  
  <div>{{test.selected}}</div>
</div>

最新更新