更新AngularJS NG-模型只对关键preSS进入? [英] Update AngularJS ng-model only on keypress enter?

查看:226
本文介绍了更新AngularJS NG-模型只对关键preSS进入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我使用一个搜索此输入字段:

I have this input field I am using for a search:

<input id="search_input" type="text" ng-model="filter.search_terms">

有我用很多其他的过滤器,以及(复选框,单选等),我有过滤器$手表,任何改变都会触发一个搜索。问题是,我不希望搜索我每次键入一个字母,只希望它拯救它只有一次我preSS进入filter.search_terms时间火文本字段。

There are many other filters I use as well (checkboxes, radio, etc) and I have a $watch on filter so any changes will fire a search. The problem is that I don't want the search to fire for the text field every time I type a letter and only want it to "save" it on the filter.search_terms only once I press enter.

有没有一种简单的方法来做到这一点还是我不得不删除NG-模型,做一个NG点击?

Is there an easy way to do this or do I have to remove the ng-model and do an ng-click with a function that sets it on enter?

推荐答案

您可以尝试添加 NG-模式选项={updateOn:变模糊'}您输入标签。应工作。

You can try adding ng-model-options="{updateOn : 'change blur'}" to your input tag. Should work.

这篇关于更新AngularJS NG-模型只对关键preSS进入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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