简体   繁体   English

使用ESC键关闭模态时传递参数

[英]Passing parameter during closing modal with ESC key

Is there a way to pass a parameter through the $modalInstance.dismiss when we close a modal using ESC key? 当我们使用ESC键关闭模式时,是否可以通过$ modalInstance.dismiss传递参数? If user close properly using 'close', then I know I can use $modalInstance.close(ctrl.anyParam) and if I use cancel button I can use $modalInstance.dismiss(ctrl.anyParam) . 如果用户使用'close'正确关闭,那么我知道我可以使用$modalInstance.close(ctrl.anyParam) ,如果我使用取消按钮,则可以使用$modalInstance.dismiss(ctrl.anyParam) This works fine since I have the promise from $modalInstance.open and depending on what user click, I can handle if the promise is resolved or rejected. 因为我从$modalInstance.open获得了承诺,并且可以根据用户单击的内容来处理承诺,所以我可以进行处理。

However, in the case where user click ESC, can I pass ctrl.anyParam so I can handle it in my reject promise? 但是,在用户单击ESC的情况下,我可以传递ctrl.anyParam以便可以在我的拒绝承诺中进行处理吗? I created plunkr here to describe my question. 我在这里创建了plunkr来描述我的问题。

唯一可以做的是通过更改config的配置并通过注册一个键侦听器以编程方式执行关闭动作(使用给定参数)来防止默认情况下使用ESC关闭模式,因为没有传递指定的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM