Skip to content

Instantly share code, notes, and snippets.

@lovelykaushik86
Created March 4, 2014 10:05
Show Gist options
  • Save lovelykaushik86/9343612 to your computer and use it in GitHub Desktop.
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">
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);
}
});
};
});
@passatgt
Copy link

passatgt commented Aug 29, 2018

you could use the built-in ng-blur instead:

ng-focus="focused=true" ng-blur="focused=false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment