我正在尝试实现具有角ng选项的loudev多重选择。问题是,它不返回错误,但选择列表是空的。
<select ng-options="item.label for item in list"
lp-multi-select multiple="multiple"
class="multi-select" ng-model="$scope.selected"></select>
发布于 2017-03-29 19:42:16
您不能在ng-模型中写入"$scope“,因为它没有定义there.So,在角控制器js中的规则是"$scope.selected”,与ng模型中的"selected“相同,例如-
ng-模型=“选定”
如果这样做,它将返回您的多个选择选项,因为object.you数组可以看到下面的示例(选择两个选项,然后单击check按钮查看结果)
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="datCtrl">
<select ng-options="item.label for item in list" multiple="multiple" class="multi-select" ng-model="selected">
</select>
<button ng-click="checkM()">Check</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('datCtrl', function ($scope) {
$scope.list=[{id:1,label:"banana"},{id:2,label:"mango"},{id:3,label:"apple"},{id:4,label:"water melon"}];
$scope.checkM=function (){
console.log($scope.selected);
};
});
</script>
</body>
</html>
https://stackoverflow.com/questions/43107679
复制相似问题