0
因此,我們有一個購物門戶項目,當我們選中該複選框它會加在車中的價值,問題是,當我們取消選中它仍然添加項目的複選框,我們再次對其進行檢查它會再次增加一個值。AngularJS複選框中vlue時選中
<input type="checkbox" id="{{p.productName}}" ng-checked="defaultCheckState" ng-click="serviceAddOn(p);" />
我也試過這個
<input type="checkbox" id="{{p.productName}}" ng-checked="defaultCheckState" ng-true-value="serviceAddOn(p);" ng-false-value="Clear"/>
角碼
$scope.IsSavingAddOn = false;
$scope.serviceAddOn = function (product) {
$scope.IsSavingAddOn = true;
$scope.total = $scope.qty * product.priceValue;
//AddToCartService.AddToCart(product.productId, 'Service', $scope.qty, product.priceValue, $scope.total, true);
$http.post("/Home/AddCart?productid=" + product.productId + "&subs=Service&qty=" + $scope.qty + "&unitprice=" + product.priceValue + "&amount=" + $scope.total)
.then(function (response) {
}).finally(function (response) {
$scope.$emit('CountCartEvent');
$scope.IsSavingAddOn = false;
});
};
複選框被禁用我無法檢查它,並且產品名稱變成這樣的代碼{{product.name}} – Woshooo
檢查控制檯是否有任何錯誤 –
錯誤:[$ compile:ctreq] Controller' ngModel」,由指令所要求的‘ngChange’,不能被發現! http://errors.angularjs.org/1.6.3/$compile/ctreq? – Woshooo