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
ng-focus and ng-blur events not triggering in Angularjs
提问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.js
in the file and it is before angular.min.js
jQuery is version v1.10.2 and Angular.js is v1.0.7.
我包含jQuery.min.js
在文件中,它是在angular.min.js
jQuery 是 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 指令,这很简单,请看这里:
回答by Vikas Chaturvedi
works with version 1.2.17 See demo
适用于 1.2.17 版 请参阅演示