çalışmak değil İşte benim kodSepete kaldır angularjs
$scope.cart = [];
$scope.addToCart = function (cat) {
var found = false;
$scope.cart.forEach(function (item) {
if (item.id === cat.product_id) {
item.quantity++;
found = true;
}
});
if (!found) {
$scope.cart.push(angular.extend({quantity: 1}, cat));
}
};
//remove from cart function
$scope.removeToCart = function (cat) {
console.log(cat.product_id);
var found = false;
$scope.cart.forEach(function (item) {
if (item.id === cat.product_id) {
item.quantity--;
found = true;
}
});
if (!found) {
$scope.cart.push(angular.extend({quantity: 1}, cat));
}
};
console.log($scope.cart);
$scope.getCartPrice = function() {
var total = 0;
$scope.cart.forEach(function (cat) {
total += cat.finalprice * cat.quantity;
});
return total;
};
"Kedi" de geçirdiğiniz şeylerle daha ayrıntılı olabilir misiniz? Eğer bir nesne varsa, bunun ayrıntılarını paylaşır mısınız lütfen? Sorular şu anda belirsiz görünüyor. Ayrıca kaldırma işlevinin nasıl çağrıldığını gösterebilir misiniz? –
i kedide product_id geçen ma, hayır bu bir nesne \t – Bhautik129