var count = 0;
var found = false;
$scope.addProduct = function (prodDetails) {
angular.forEach($scope.cartProducts, function (newProduct, index) {
var a = angular.equals(newProduct, prodDetails);
found = true;
});
if (found) {
prodDetails['qty']++;
} else {
prodDetails['qty'] = 0;
$scope.cartProducts.push(prodDetails);
count++;
}
console.log($scope.cartProducts);
// count++;
$rootScope.$broadcast('addProduct-ToCart', $scope.cartProducts);
console.log('check');
}
// cartController
$scope.cartItems = [];
cartFactory.cartProducts().then(function (response) {
$scope.cartItems = response.data;
// console.log(response.data);
console.log($scope.cartItems);
}, function (error) {
console.error(error);
});
$rootScope.$on('addProduct-ToCart', function (event, data) {
console.log('check');
});