I'm attempting to eliminate a user from a blacklist feature. The goal is to remove the user from the list, splice out the JSON row, and update the mat-table in Angular.
My attempt using
delete this.blacklistGroupTable[i]
does not alter the JSON object as expected.
Another approach I tried was
this.blacklistGroupTable.splice(i, 1)
, but it resulted in an error saying _this.blacklistGroupTable.splice is not a function
What could be causing this issue?
https://i.sstatic.net/3TUBA.png
unblockUser(userId: string, username: string, i: number) {
const dialogRef = this.dialog.open(ConfirmationBlacklistComponent, {
panelClass: "dialogBoxStyler",
data: {
username: username
}
});
dialogRef
.afterClosed()
.pipe(takeUntil(this.destroy))
.subscribe(result => {
if (result) {
alert("I: " + i);
this.blacklistGroupTable.splice(i, 1);
// delete this.blacklistGroupTable[i];
console.log("this.blacklistGroupTable");
console.log(this.blacklistGroupTable);
this.dataSource.data = this.blacklistGroupTable;
this.submitListingService
.sendUserToBlacklist(this.userId, this.bidderId, "UNBLOCK")
.pipe(takeUntil(this.destroy))
.subscribe(res => {
console.log("res");
console.log(res);
});
} else {
this.blacklistUserDecision = false;
return;
}
});
}