Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal组件功能建议(open() and close() for Modal) #118

Closed
spawpaw opened this issue Aug 21, 2017 · 1 comment · Fixed by #125
Closed

Modal组件功能建议(open() and close() for Modal) #118

spawpaw opened this issue Aug 21, 2017 · 1 comment · Fixed by #125

Comments

@spawpaw
Copy link

spawpaw commented Aug 21, 2017

I'm submitting a...


[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Support request => Please do not submit support request here

Current behavior

目前的modal组件只能通过中间变量开启和关闭,有些情景下很麻烦

<!--the current `nz-modal` component can only be open/closed by  intermediate variables-->
<button nz-button (click)="modal.nzVisible=true">
  <span>show modal</span>
</button>

<nz-modal #modal [nzTitle]="'喵喵喵'" [nzContent]="'汪!汪!汪!'"
          (nzOnCancel)="modal.nzVisible=false">
</nz-modal>

Expected behavior

如果有了open和close方法就方便很多(而且对原有的功能也没有任何影响)

<!-- by using the #modal var, now we can easily open/close the modal  -->
<button nz-button (click)="modal.open()">
  <span>show modal</span>
</button>

<nz-modal #modal [nzTitle]="'喵喵喵'" [nzContent]="'汪!汪!汪!'"
          (nzOnCancel)="modal.close()">
</nz-modal>

如果可以,还可以添加其他方法,如isOpen(),setLoading(boolean)等,这样在ts中只要添加一个ViewChild变量就可以了,而不是各种标识变量
current:

//too many vars make us confused(especially when you have many modals)
isXXXModalLoading=false;
isXXXModalOpen=false;

isYYYModalLoading=false;
isYYYModalOpen=false;

suppose to be:

//one var for all 
@ViewChild("modalA")
modalA;
@ViewChild("modalB")
modalB;

//use:
modalA.open()
modalA.setLoading(true)
modalA.setLoading(false)
modalA.close()
@spawpaw spawpaw changed the title Modal组件功能建议(为Modal添加open()和close()方法) Modal组件功能建议(open() and close() for Modal) Aug 21, 2017
vthinkxie pushed a commit that referenced this issue Aug 31, 2017
…#125)

use #modal.open() instead of set nzVisible=true
use #modal.close() instead of set nzVisible=false
use #modal.setConfirmLoading(loading:boolean) instead of set confirmLoading

close #118
@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants