I know you can make a modal to stay opened by returning false from nzOnOK field:
this.modal.confirm({
nzTitle: 'Do you Want to delete these items?',
nzContent: 'When clicked the OK button, this dialog will stay opened',
nzOnOk: async () =>{
return false;
}
});
But in my case, I have a method called from a service that might return a promise rejection or not.
I would like to make the modal stay opened if the service call fails
this.modal.confirm({
nzTitle: 'Do you Want to delete these items?',
nzContent: 'Some content',
nzOnOk: async () =>{
await this.myService.someMethod(); // this throws error and it should make the modal stay open
}
});
Is there a config I am missing because I don't find anything in documentation that says the modal to stay open in case of promise rejection.
Also, I don't want to use try catches or temporary variables to do this since it will defy the purpose of the rejection I am using.
The modal should stay opened the callback is return false
or Promise<false>
:
Here's an example with promise:
export class MyService {
someMethod() {
return Promise.reject();
}
}
...
nzOnOk: () => {
return this.myService.someMethod().then(res => !!res).catch(() => false);
}