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

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

问题描述

的问题:结果
我一直无法接受用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).

坏的部分是,我不得不modifiy的模板/模式/窗口,我会很高兴地离开未受污染的,如果可能的话。

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

我很想结果
我很想干脆把 NG-输入指令在我的模式,而无需修改默认的模板

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

额外结果
我也尝试添加了事件13的模式指令,但在 modal.close <我不能错过任何结果/ code>,所以我放弃了这条道路。

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

任何想法?

推荐答案

AngularJS支持此为默认值。

AngularJS support this be default.

添加&LT;形式&GT; 在你的模板(modal.html)标记,并添加 NG-提交指令
例如。

Add a <form> tag in your template (modal.html) and add ng-submit directive e.g.

<form name="questionForm" ng-submit="ok()">
  <div class="modal-header">
    <h3 class="modal-title">{{title}}</h3>
  </div>
  // the rest of the code here
</form>

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

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