Created
March 4, 2014 10:05
-
-
Save lovelykaushik86/9343612 to your computer and use it in GitHub Desktop.
AngularJS ngFocusOut directive - If you are new in angularJs you can use this by adding in your HTML tag. e.g. <input type = "text" ng-focus-out = "$scope.bool = true">
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appStrapDirectives.directive('ngFocusOut', function( $timeout ) { | |
return function( $scope, elem, attrs ) { | |
$scope.$watch(attrs.ngFocusOut, function( newval ) { | |
if ( newval ) { | |
$timeout(function() { | |
elem[0].focusout(); | |
}, 0, false); | |
} | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you could use the built-in ng-blur instead:
ng-focus="focused=true" ng-blur="focused=false"