“Possibly unhandled rejection” when closing ngDialog

 
 

Found my solution at: https://github.com/angular/material/issues/10369

When using the openConfirm function use:

TypeScript:

ngDialog

.openConfirm(dialogOptions)

.catch(function dialogCloseErrorCallback(reason: any) {

        // ngDialog v1.4.0 throws an exception, when closing the dialog with reason “undefined”.

        // Prevent this error:

    if (reason !== undefined) {

        throw
new Error(`Error when closing the dialog: [${reason}].`);

    }

});

 

When using open, use:

 

const openResult = self.ngDialog.open(dialogOptions);

if (openResult.closePromise) {

    openResult.closePromise.catch(function dialogCloseErrorCallback(reason: any) {

            // ngDialog v1.4.0 throws an exception, when closing the dialog with reason “undefined”.

           // Prevent this error:

        if (reason !== undefined) {

            throw
new Error(`Error when closing the dialog: [${reason}].`);

        }

    });

}

Leave a Reply

Your email address will not be published. Required fields are marked *