user56690
user56690

Reputation: 259

upgrade angularjs code from 1.0.3 to 1.4.9

i am new to angularJS and trying to get the code given in fiddle - http://jsfiddle.net/atXAC/11/ upgraded to 1.4.9.

myApp.directive('ngCustomblur', ['$parse', function($parse) {
    return function(scope, element, attr) {
        var fn = $parse(attr['ngCustomblur']);      
        element.bind('blur', function(event) {        
        scope.$apply(function() {
            fn(scope, {$event:event});
        });
    });
}
}]);

Please let me know what changes need to be done. currently the code is in 1.0.3.

Thanks in advance.

Upvotes: 2

Views: 47

Answers (1)

dreamweiver
dreamweiver

Reputation: 6002

Actually the issue is that the later versions of angularjs library made it a standard to create a controller, which is a little different from the current syntax which you are using in jsfiddle.

JS CODE:

//defining a controller
myApp.controller('MyCtrl',['$scope',MyCtrl]);

function MyCtrl($scope) {
   $scope.onBlur = function(){        
      $scope.hasFocus = false;
   }
}

Working demo on JSFiddle

Upvotes: 1

Related Questions