我正在尝试传递ng-model="alertThreshold.value"
的值,但是当我点击<a class="spin-up" data-spin="up" ng-click = "getAlertThreshold(alertThreshold.value)"><i class="fa fa-caret-up"></i></a>
或<a class="spin-down" data-spin="down ng-click = "getAlertThreshold(alertThreshold.value)"" ><i class="fa fa-caret-down"></i></a>
时
它只是调用函数而不更新值,值总是= 10.
<div class="input-group spinner" data-trigger="spinner">
<input type="text" class="form-control text-center" value="0" data-rule="quantity" ng-model="alertThreshold.value" min="0" max="50" ng-change ="getAlertThreshold(alertThreshold.value)">
<div class="input-group-addon">
<a class="spin-up" data-spin="up" ng-click = "getAlertThreshold(alertThreshold.value)"><i class="fa fa-caret-up"></i></a>
<a class="spin-down" data-spin="down" ng-click = "getAlertThreshold(alertThreshold.value)"><i class="fa fa-caret-down"></i></a>
</div>
</div>
并在我的控制器中:
$scope.alertThreshold = {
value: 10
};
$scope.getAlertThreshold = function(value){
console.log("value:",value)
$scope.alertThreshold.value = value;
}
答案 0 :(得分:0)
$scope.alertThreshold.value
的值始终相同,因为获取输入的值。就像$scope.alertThreshold.value = $scope.alertThreshold.value
每ng-click
或ng-change
答案 1 :(得分:0)
ng-click =“getAlertThreshold(++ alertThreshold.value)”ng-click =“getAlertThreshold( - alertThreshold.value)”可以解决问题。