Making use of Dialogs in Material 2 (MdDialog)
Tarik A
18629

When ‘true’ is returned after clicking “Confirm” I receive “true” in the html as you have it setup but I can’t figure out how to work with that. I’ve tried:

deleteMember(selectedMember) {
// Call the confirm dialog component
this.confirmService
.confirm('Confirm Delete', 'Are you sure you want to do this?')
.subscribe(res => this.result = res, err => err);
console.log("Value for result = ", this.result);

if (this.result === true)
{ console.log('If true then delete. ', this.result);
this.membersAdminService.deleteMember(selectedMember.$key);
}
}

However, the deleteMember in the if statement doesn’t get called until I click the “Delete” button again in my html that starts this process. This second click brings up the dialog again and at the same time runs that if statement and deletes the member. Obviously I’m still far from a wiz with observables! I think my example could be helpful to others who are trying to capture that ‘true’ and use it to do something. Any idea what is wrong with my code?

Show your support

Clapping shows how much you appreciated SV Startup Lab’s story.