我有一个选项框,其中包含来自我后端的选项:
$http.get($rootScope.appUrl + '/nao/abb/getDataOptionsForAbb/' + $rootScope.abbForm)
.then(function(response) {
$scope.abbOptions = response.data;
//console.log($scope.abbOptions);
});
$scope.onChangeSuperCustomer = function() {
console.log($scope.selectedSupercustomer);
}
我正在使用ng-options:
<td><select class="form-control input-sm2" ng-model="selectedSupercustomer" ng-options="item.superkund_id as item.namn for item in abbOptions" ng-change="onChangeSuperCustomer()" ><option value=''>Select</option></select></td>
我的console.log($ scope.selectedSupercustomer)的输出错误。这不是我在选择框中选择的值。
答案 0 :(得分:0)
试试这个:
<td><select class="form-control input-sm2" ng-model="selectedSupercustomer" ng-options="item.superkund_id as item.namn for item in abbOptions" ng-change="onChangeSuperCustomer(selectedSupercustomer)" ><option value=''>Select</option></select></td>
或者:
<td><select class="form-control input-sm2" ng-model="selectedSupercustomer" ng-options="item.superkund_id as item.namn for item in abbOptions" ng-change="onChangeSuperCustomer()" > <option value=''>Select</option></select></td>
JS:
$scope.onChangeSuperCustomer = function(selectedSupercustomer) {
console.log(selectedSupercustomer);
}
或强>
$scope.onChangeSuperCustomer = function() {
console.log($scope.selectedSupercustomer);
}