什么是element.bind和element.on之间的区别 [英] What's the difference between element.bind and element.on
问题描述
伙计们,
我一直在关注angularjs指令的例子。我看到一些人使用:
I have been following examples of angularjs directives. I see some people use:
element.bind('click',callback)
而其他人使用:
element.on('click',callback)
这两者有什么,哪些应该被应用之间的区别任何线索是什么时候?
Any clue on what is the difference between the two and which should be applied when ?
推荐答案
有没有功能上的差异。 jQuery的正式去precated比。对
之外的所有绑定语法。由于jqlite angular.element
是基于jQuery的,他们把语法。对
序是为那些更柔顺谁使用jQuery和角度在一起。 jqlite仍允许 .bind
来向后兼容(一样的jQuery)。
There is no functional difference. jQuery officially deprecated all binding syntaxes other than .on
. Because jqlite angular.element
is based on jQuery, they moved the syntax to .on
inorder to be more compliant for those who use jQuery and Angular together. jqlite still allows for .bind
to be backwards compatible (as does jQuery).
您可以了解更多关于这里的区别: jQuery的.bind()对。对()
You can learn more about the differences here : jquery .bind() vs. .on()
这篇关于什么是element.bind和element.on之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!