Ng-zorro-antd: promise return false in Modal component can't stop [button ok] loading

Created on 17 Dec 2018  ·  6Comments  ·  Source: NG-ZORRO/ng-zorro-antd

Version

7.0.0-rc.1

Environment

any

Reproduction link

https://stackblitz.com/edit/angular-efvfiu?file=src/app/app.component.ts

Steps to reproduce

 this.confirmModal = this.modal.confirm({
      nzTitle: 'Do you Want to delete these items?',
      nzContent: 'When clicked the OK button, this dialog will be closed after 1 second',
      nzOnOk: () => new Promise((resolve, reject) => {
        // setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
         setTimeout(() => {
           return false;
         }, 1000);
      }).catch(() => console.log('Oops errors!'))
    });

What is expected?

when I return false, the [loading status] in OK button should be removed and back to normal status

What is actually happening?

always loading

Other?

Most helpful comment

resolve(false)

All 6 comments

@xiehongyang Must be call resolve() in setTimeout if you hope closed.

@xiehongyang Must be call resolve() in setTimeout if you hope closed.

yes, I know that, both resolve() and reject() can close the modal, but now If I want keep the Modal open, I pass return false to stop the Modal close, the loading in button OK can't be removed, how could I remove the loading in that button

resolve(false)

resolve(false)
@cipchk 这个好像没用,modal框还是会消失

@St-Yukio 你方法里是promise吗,我试过了,是可以阻止 modal框关闭的

@St-Yukio 你方法里是promise吗,我试过了,是可以阻止 modal框关闭的

@xiehongyang 我知道原因了 谢谢...

Was this page helpful?
0 / 5 - 0 ratings