我想从我的结果中获取所有选定的内容,以便在我的 Controller 中使用。
<div class="form-group" ng-repeat="att in arr track by $index" ng-hide="check">
<div class="col-md-3">
<label for="phone">{{att.name}}</label>
</div>
<div class="col-md-9">
<select class="form-control" ng-model="user.charactValue" multiple="true">
<option ng-repeat="itemss in att.value track by $index" value="{{itemss}}" >{{itemss}}</option>
</select>
<div class="text-center"><a data-toggle="modal" data-target="#addNewCharacteristic" ng-click="getObj(att)">Добави</a></div>
</div>
</div>
<input type="submit" ng-click="companyBusinessAsset">
$scope.companyBusinessAsset = function() {
console.log ($scope.charactValue);
// this return Undefined
};
down代码正在使用,但是每次都进入if。
$scope.charactValue = [];
$scope.$watch ('selected', function(nowSelected) {
$scope.selectedValues = [];
console.log(nowSelected)
// this return Undefined
console.log('dddd')
if (!nowSelected) {
console.log("IFFFFFF");
return;
}
angular.forEach ($scope.charactValue, function(val) {
console.log(val);
$scope.charactValue.push (val.id.toString());
});
});
最佳答案
尝试将 ng-multiple="true"
添加到您的选择
中。
关于javascript - 如何从 Controller 中的多个选择选项中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37138032/