AngularJS - 使用 ENTER 键接受 ui.bootstrap 模式 [英] AngularJS - Accept a ui.bootstrap modal with ENTER key

查看:22
本文介绍了AngularJS - 使用 ENTER 键接受 ui.bootstrap 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:
我一直无法接受带有 ENTER 键的模态窗口

The Issue:
I've been unable to to accept a modal window with the ENTER key

我已经修改了默认的 Plunker 以向您展示我从现在起所做的事情 --> 这里

I have modified the default Plunker to show you what I've done since now --> Here

我有什么:
简而言之,输入键被模态识别,但它不会触发我的功能(范围问题,我怀疑).

What I have:
Briefly, the ENTER key is recognized by the modal, but it doesn't trigger my function (scope issues, I suspect).

不好的部分是我必须修改template/modal/window,如果可能的话,我很乐意保持原样.

The bad part is that I had to modifiy the template/modal/window, which I would gladly left unspoiled, if possible.

我喜欢什么
我很想简单地将 ng-enter 指令放在我的模态中,而不修改默认模板

What I would love
I would love to simply put the ng-enter directive in my modal, without modifying the default template

额外
我还尝试将事件 13"添加到 modal 指令,但我无法在 modal.close 中传递任何结果,所以我放弃了这条路

Extra
I've also tried to add the "event 13" to the modal directive, but I couldn't pass any result in the modal.close, so I dropped that road

有什么想法吗?

推荐答案

检查我的 Plunker.您应该将 ng-enter 添加到确定"按钮.

Check my Plunker. You should add ng-enter to "OK" button.

<button class="btn btn-primary" ng-enter="ok();" ng-click="ok()">OK</button>

也许您正在寻找更通用的东西,我不确定.那么你可以考虑观察者.但我个人觉得这更好,因为我们没有任何监听模态事件的持续观察者.

Maybe you are looking for something more generic, I'm not sure. Then you might consider watchers. But personally I find this better since we don't have any constant watcher which listens modal event.

这篇关于AngularJS - 使用 ENTER 键接受 ui.bootstrap 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆