This is our controller code
/**
* @Summary: setProductInAlbum function, to create album
* @param: index, productObj
* @return: callback(response)
* @Description:
*/
$scope.allAlbums = [];
$scope.sellerUserTypeKeyId = [];
$scope.getAlbumsBySellerUserTypeKeyId = function() {
$scope.sellerUserTypeKeyId = Number(AUTH.userTypeKeyId);
var PRODUCT_DB_REF = firebase.database().ref('datastore/productsAlbum');
PRODUCT_DB_REF.orderByChild("sellerUserTypeKeyId").equalTo($scope.sellerUserTypeKeyId)
.on("value", function(snapshot) {
var value = snapshot.val();
if(value != null) {
$scope.allAlbums = objToArray(value);
}
});
}
/**
* @Summary: addProductKeyInAlbum function, to filter the connected user
* @param: index, isChecked, productObj
* @return: callback(response)
* @Description:
*/
$scope.getAlbumsBySellerUserTypeKeyId();
$scope.selectedProductKey = [];
$scope.getSelectedProductObject = [];
$scope.addProductKeyInAlbum = function(index, isChecked, productObj) {
$scope.productObj = productObj;
if(isChecked) {
//PUSH THE PRODUCT kEYID INO THE ARRAY AND PASS TO THE getProduct FUNCTION
$scope.selectedProductKey.push($scope.productObj.keyId);
var data = {
keyId : $scope.selectedProductKey
}
//CALL THE getProduct FUNCTION FOR GET THE LIST OF THE SELCETD OBJECTS
SellerDashboardService.getProduct(function(response) {
if(response != null) {
if (response.data.isSuccess) {
$scope.getSelectedProductObject = response.data.UserProductList;
}
}
}, data);
//HERE WE WEILL BLANK THE ARRAY AFTER THE RESPONSE IS RECEIVED FROM THE SERVICE
} else {
//SPLICE THE PRODUCT kEYID FROM THE ARRAY
$scope.selectedProductKey.splice(index, 1);
console.log($scope.selectedProductKey);
}
}
I have an 2 array if the id will be match checkbox will be checked but if id will be not match checkbox is uncheck but in my condition both the checkbox will be checked
<div id="removeSelectedProductKey" class="checkbox albumSection w3-margin-top-10" ng-repeat="productObject in getSelectedProductObject">
<div class="w3-margin-top-10" ng-repeat="albumList in allAlbums">
<div>
<input type="checkbox" ng-checked="productObject.keyId == albumList.productKey" ng-click="removeSelectedProductKey($event, $index)" />
</div>
<div>
<input type="checkbox" ng-checked="productObject.keyId != albumList.productKey" />
</div>
</div>
<label>
</label>
<br>
</div>
<div id="removeSelectedProductKey" class="checkbox albumSection w3-margin-top-10" ng-repeat="productObject in getSelectedProductObject">
<div class="w3-margin-top-10" ng-repeat="albumList in allAlbums">
<div>
<input type="checkbox" ng-checked="productObject.keyId == albumList.productKey" ng-click="removeSelectedProductKey($event, $index)" />
</div>
<div>
<input type="checkbox" ng-checked="productObject.keyId != albumList.productKey" />
</div>
</div>
<label>
</label>
<br>
</div>
how to resolve this issue?