javascript - ng-focus and ng-blur not working while ng-click works fine in input element - Stack Overflow

<input ng-model="t" ng-change="updateV()" ng-blur="blur()" ng-focus=&q

<input ng-model="t" ng-change="updateV()" ng-blur="blur()" ng-focus="blur()" ng-click="blur()"/>

I make a fiddle to this question:/

anyone can help? thx!

<input ng-model="t" ng-change="updateV()" ng-blur="blur()" ng-focus="blur()" ng-click="blur()"/>

I make a fiddle to this question:http://jsfiddle/tjfdfs/6Mqd6/

anyone can help? thx!

Share Improve this question asked Sep 16, 2013 at 8:04 tjfdfstjfdfs 73910 silver badges26 bronze badges 5
  • Which version are you using? Try using version 1.2.0 – AlwaysALearner Commented Sep 16, 2013 at 8:08
  • I read source of todoMVC of angular. he write todoBlur and todoFocus directives manually. So can I conclude this: I still need to write these two directives by myself? – tjfdfs Commented Sep 16, 2013 at 8:11
  • Not if you 're using version 1.2.0. in which these are already included. – AlwaysALearner Commented Sep 16, 2013 at 8:14
  • @CodeHater, thanks, I use 1.1.1 because it's latest version provided by jsfiddle . I will try 1.2.0 and see if it can work. – tjfdfs Commented Sep 16, 2013 at 8:15
  • You can load the version of your choice using the <script tag in the fiddle. – AlwaysALearner Commented Sep 16, 2013 at 8:50
Add a ment  | 

2 Answers 2

Reset to default 3

Both ng-focus and ng-blur directives are not supported in the current stable branch (1.0.x). The corresponding code has been added to master just 2 months ago.

Expect to have them in 1.2.0 branch. Actually, if you're able to work with the products marked as unstable in your application, try 1.2.0rc1 to have them supported already.

I'm working with angular 1.07 and as much as I know it does not support ng-blur nor ng-focus at all. You will have to write them by your self as follows.

var myApp = angular.module('myApp', ['App_ui']);
angular.module("App_ui", []).directive('uiBlur', function () {
  return function (scope, elem, attrs) {
      elem.bind('blur', function () {
          scope.$apply(attrs.uiBlur);
      });
   };
 });

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745624251a4636708.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信