I imported a custom confirm dialog into a function and "this" went undefined everywhere except for the dialog function.
This is the function:
onDelete(CTId) {
this.confirmDialogService.confirmThis(
"Confirm Delete",
function() {
this.service.deleteContactDetail(CTId).subscribe(
res => {
this.service.refreshList();
this.toastr.warning("Deleted Successfully", "Contact Details");
},
err => {
console.log(err);
this.toastr.error("Failed to Delete");
}
);
},
function() {
console.log("closed dialog");
}
);
}
For the confirmDialogService this is defined like so this: this
and everywhere else it's any