I close a MatDialog with true
and false
, but somehow I cannot retrieve these boolean values in the correct way. See my code below. The shouldRefresh
method should not be called, and yet it is.
dialogRef.afterClosed()
.subscribe((result: any): void => {
console.log('RESULT', result); // Returns false
if ((result as boolean)) {
console.log('Its FALSE ?!?', result); // Fires
this.shouldRefresh.next(true);
}
});
I cannot figure out what is going wrong.
I figured it out. I had:
<button mat-dialog-close="false">Cancel</button>
But instead I should have added brackets like so:
<button [mat-dialog-close]="false">Cancel</button>
This passes the result as a boolean
and not as a string
.
The joys of programming.