mercredi 5 avril 2017

AngularJS checkbox remove vlue when unchecked

So we have a shopping portal project, when we checked the checkbox it will plus the value in the cart, the problem is when we unchecked the checkbox it's still adding an item and we checked it again it will add again a value.

picture of adding a other service

     <input type="checkbox" id="" ng-checked="defaultCheckState"  ng-click="serviceAddOn(p);" />

I also tried this

     <input type="checkbox" id="" ng-checked="defaultCheckState" ng-true-value="serviceAddOn(p);" ng-false-value="Clear"/>

Angular code

    $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;
        });
};




Aucun commentaire:

Enregistrer un commentaire