AngularJS - 接受ui.bootstrap模式与ENTER键模式、ui、AngularJS、ENTER

2023-09-13 04:35:29 作者:゛未来只靠自己つ

的问题:结果我一直无法接受用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 ,所以我放弃了这条道路。

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.

添加<形式> 在你的模板(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>