jQuery Angularjs 中未触发的 ng-focus 和 ng-blur 事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18549142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:55:45  来源:igfitidea点击:

ng-focus and ng-blur events not triggering in Angularjs

javascriptjqueryangularjs

提问by Program_Sauce

<input type='text' ng-focus='tryFunc()'> </input>

The function tryFunc()is not called when the input box is focused.

tryFunc()当输入框聚焦时不会调用该函数。

I am including jQuery.min.jsin the file and it is before angular.min.jsjQuery is version v1.10.2 and Angular.js is v1.0.7.

我包含jQuery.min.js在文件中,它是在angular.min.jsjQuery 是 v1.10.2 版本和 Angular.js 是 v1.0.7 之前。

What may be happening?

可能会发生什么?

回答by Wagner Francisco

ngFocus is not available on Angular 1.0.7. It's available on Angular 1.2.

ngFocus 在 Angular 1.0.7 上不可用。它在 Angular 1.2 上可用。

You can create your own ngFocus directive, it's quite simple, have a look here:

您可以创建自己的 ngFocus 指令,这很简单,请看这里:

https://gist.github.com/eliotsykes/5394631

https://gist.github.com/eliotsykes/5394631

回答by Vikas Chaturvedi

works with version 1.2.17 See demo

适用于 1.2.17 版 请参阅演示

https://gist.github.com/anonymous/35636e7c020d50aeab18

https://gist.github.com/anonymous/35636e7c020d50aeab18