如何在AngularJS中添加点击和双击控件? [英] How can I add a click and double click control to a row with AngularJS?

查看:136
本文介绍了如何在AngularJS中添加点击和双击控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < tbody>如果我有AngularJS HTML创建一个 
< tr data-ng-repeat =grid.data中的行>
< td> {{row.id}}< / td>
< td> {{row.text}}< / td>
< / tr>
< / tbody>

我如何添加功能,只需点击一行即可突出显示该行并点击两次使用 row.id 调用一个函数?有没有一个 AngularJS 方法来做到这一点,还是我必须使用 jQuery ?我怀疑唯一的方法是使用 jQuery ,但我觉得我应该先问一个 AngularJS 问题。



感谢


解决方案

我发现下面从jQuery的网站:




将处理程序绑定到同一元素的click和dblclick事件是不可取的,触发事件的顺序因浏览器而异浏览器,其中一些在dblclick之前收到两个点击事件,而另一些则只收到一个点击事件。



最好能找到另一种方式来实现它,比如使用鼠标悬停和点击事件收集而不是点击并双击收集。


If I have AngularJS HTML that creates a table like this:

<tbody>
   <tr data-ng-repeat="row in grid.data">
      <td>{{ row.id }}</td>
      <td>{{ row.text }}</td>
   </tr>
</tbody>

How could I add in functionality so that one click on a row makes just that row highlighted and two clicks calls a function with the row.id? Is there an AngularJS way to do this or would I have to use jQuery? I suspect the only way to do this is with jQuery but feel I should ask as an AngularJS question first.

Thanks

解决方案

I found below from Jquery's website:

" It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events before the dblclick and others only one. "

It's better you can find another way to implement it, such as using the mouse hover and click event togather but not click and double click togather.

这篇关于如何在AngularJS中添加点击和双击控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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