NG-重点射击两次,NG-模糊从不闪光 [英] ng-focus firing twice and ng-blur never fires

查看:132
本文介绍了NG-重点射击两次,NG-模糊从不闪光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有角相当的经验,但这似乎是一些在与DOM事件传播的方式一个较低的水平发生。出于某种原因,在短短我的应用程序的一部分,我有 NG-焦 NG-模糊在同一个输入,而 NG-焦事件触发两次, NG-模糊永远不会触发。

I am fairly experience with Angular by now, but this appears to be something happening at a lower level with the way DOM events are propagated. For some reason in just part of my application I have ng-focus and ng-blur on the same input, but the ng-focus event fires twice and the ng-blur never fires.

<input type="text" ng-focus="doFocus()" ng-blur="doBlur()" />

然后在我的控制器

Then in my controller

$scope.doFocus = function(){
    console.log('focus');
}

$scope.doBlur = function(){
    console.log('blur');
 }

当我检查我的控制台,我看到2重点,并没有模糊的消息......我已经在我的网站的其他部分测试这一点,它在某些人的作品。我的猜测是它有事情做与DOM,但我甚至试过除了输入在页面上拉出基本上一切,它仍然没有正常工作。没有人有任何想法可能是什么原因?

When I inspect my console, I see 2 "focus" and no "blur" messages... I have tested this in other parts of my website and it works in some others. My guess is it has something to do with the DOM, but I have even tried pulling out basically everything on the page except the input and it still didn't work correctly. Does anyone have any idea what could cause this?

更新

一些调试后,我注意到,焦点事件在浏览器的范围发射一次,但事​​件AngularJS世界触发两次。我设置一个断点上使用Chrome开发工具的所有焦点事件,它只会打一次,但如果我登录到控制台中的角 $事件,我可以看到完全一样的具有相同时间戳$事件被触发的角度的两倍。

After some more debugging, I noticed that the focus event is fired once in the scope of the browser, but the event triggers twice in the world of AngularJS. I set a breakpoint on all Focus events using Chrome Dev Tools and it only would hit once, but if I log the Angular $event in the console, I can see the EXACT same $event with the same timestamp being triggered twice in Angular.

推荐答案

好吧..所以这是一种奇怪的一个。没有找到解决自己之后,我有一个同事试图瑞普他的机器上我的问题。当然,它的工作就好了他..这让我觉得这是我的浏览器,所以我卸载并重新安装了Chrome的新鲜的实例,而现在一切都只是罚款...不知道发生了什么事我的Chrome中造成DOM事件来获得各种搞砸了,但至少我想通了。

Ok.. so this is kind of a strange one. After not finding a solution myself, I had a coworker try to repro my problem on his machine. Of course, it worked just fine for him.. this made me think it was my Chrome, so I uninstalled and re-installed a fresh instance of Chrome and now it everything is just fine... not sure what happened to my Chrome that caused the DOM events to get all kinds of fucked up, but at least I figured it out.

希望这有助于任何人都可能会在未来有这个问题。

Hopefully this helps anyone that may have this problem in the future.

更新

我也意识到问题的Chrome扩展: AngularJS Batarang

I realized the problem was the Chrome Extension: AngularJS Batarang

该插件与我的DOM事件搞乱,造成它们无法正常开火。我删除了Chrome的扩展和一切开始工作!

This plugin was messing with my DOM events and caused them to not fire correctly. I removed the extension from Chrome and everything started working!

这篇关于NG-重点射击两次,NG-模糊从不闪光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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