user56690 user56690 - 4 months ago 4x
AngularJS Question

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 - 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.


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.


//defining a controller

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

Working demo on JSFiddle