Hello
i have to get the indexOf selected Object but i got every time return -1 tell me whats the wrong in my code?
addOrRemoveSubcategory(event:any, subCategroyObject: any) {
//For firestore - Here we will hold the subcateoryObject and push into array
this.checkedCategoryObject = {
"id" : subCategroyObject.keyId,
"subCategoryName" : subCategroyObject.subCategoryName
}
if(event.checked) {
this.selectedSubCategoryKeyId = subCategroyObject.keyId;
//Push only if not eixst in the array
if(this.selectedSubCategoryArray.indexOf(this.checkedCategoryObject.id) == -1){
this.selectedSubCategoryArray.push(this.checkedCategoryObject);
}
} else {
this.selectedSubCategoryKeyId = subCategroyObject.keyId;
var index = this.selectedSubCategoryArray.indexOf(this.checkedCategoryObject);
this.selectedSubCategoryArray.splice(index, 1);
}
}
