检测窗焦点成角度的方式? [英] Detecting window focus the angular way?

查看:62
本文介绍了检测窗焦点成角度的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有很好的角度检测窗口焦点的方法?我正在使用html5通知,并且仅在窗口焦点未对准时才触发.

Is there a good angular way to detect window focus? I am using html5 notifications and I would like to only fire if the window is out of focus.

谢谢!

推荐答案

有一个内置的角度指令ngFocus 此处如果将其连接到身体上可能会有所帮助

There's a built-in angular directive ngFocus here maybe it helps if you attach it to the body

<window, input, select, textarea, a
  ng-focus="">
...
</window, input, select, textarea, a>

对于窗口焦点,有一个$window包装器,您可以执行以下操作:

For window focus, there's the $window wrapper and you can do something like:

 $window.onfocus = function(){
   console.log("focused");
 }

这篇关于检测窗焦点成角度的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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