Reputation: 259
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
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;
}
}
Upvotes: 1