Created
December 19, 2014 09:40
-
-
Save batandwa/3f65406745f7abdf3f85 to your computer and use it in GitHub Desktop.
A work-arount to getting the target element in ng-change.
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
<input type="text" ng-focus="focusCallback($event)" ng-change="changeCallback()"> |
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
$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; | |
}; |
Nice solution! For version, where ng-focus is not available a workaround could be to use ng-click...
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
Smart enough ;)