Skip to content

Instantly share code, notes, and snippets.

@batandwa
Created December 19, 2014 09:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save batandwa/3f65406745f7abdf3f85 to your computer and use it in GitHub Desktop.
Save batandwa/3f65406745f7abdf3f85 to your computer and use it in GitHub Desktop.
A work-arount to getting the target element in ng-change.
<input type="text" ng-focus="focusCallback($event)" ng-change="changeCallback()">
$scope.targetField = null;
$scope.changeCallback = function() {
$scope.searchResults = Beneficiaries.search($scope.searchTerm);
};
$scope.focusCallback = function($event) {
if($event.target === null) {
return;
}
$scope.targetField = $event.target;
};
@pmaoui
Copy link

pmaoui commented Jun 23, 2016

Smart enough ;)

@mecograph
Copy link

Nice solution! For version, where ng-focus is not available a workaround could be to use ng-click...

@Bhuvan-Arora
Copy link

You are awesome man ! Thanks for the Smart Solution, It saved my time. :)

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