如何AngularJS内部捕获的事件,如“的onclick”,“的onchange”? [英] How does AngularJS internally catch events like 'onclick', 'onchange'?
问题描述
我以前在输入元素NG-模式,并观察到Chrome检查该元素。但是,输入元素的每个onxxx物业(包括的onchange)为空。那么,怎样才能AngularJS捕获的onchange事件由用户输入触发的?
I used "ng-model" in input element and observed that element with chrome inspector. But every onxxx properties(including onchange) of input element was null. Then, how can AngularJS catch "onchange" event triggered by user input?
推荐答案
如果,在Chrome的事件监听器选项卡,检查标准的文本输入元素(附NG-模型),你会看到它有附加两个事件侦听器: $摧毁
和输入
。
If, in Chrome's Event Listeners tab, you inspect a standard text input element (with ng-model attached) you will see that it has two event listeners attached: $destroy
and input
.
角,在默认情况下,监听输入
事件,并且,如果它不是由浏览器所支持,它会回落到 KEYDOWN
+ 更改
事件。
Angular, by default, listens for input
event, and, in case it's not supported by the browser, it will fall back to keydown
+ change
events.
事件与jQlite的绑定方法绑定(除非你有一个完整的jQuery包括,在这种情况下,它的绑定方法将接管)。
Events are binded with jQlite's bind method (unless you also have a full jQuery included, in which case its bind method will take over).
这可以检查自己举例输入元素是在输入中找到[邮件] 指令文档页。
Example input element that you can inspect yourself is found on input [email] directive documentation page.
确切的行。 2.0rc1)负责处理输入事件。
这篇关于如何AngularJS内部捕获的事件,如“的onclick”,“的onchange”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!