Created
October 11, 2013 13:11
-
-
Save wallin/6934406 to your computer and use it in GitHub Desktop.
Angular JS directive that adds $focus attribute to form elements
This file contains hidden or 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
angular.module('ui.inputFocus', []).directive "input", [-> | |
restrict: "E" | |
require: '?^ngModel' | |
link: (scope, elm, attrs, ctrl) -> | |
return unless ctrl | |
ctrl.$focus = no | |
elm.focus -> | |
scope.$apply(-> ctrl.$focus = yes) | |
elm.blur -> | |
scope.$apply(-> ctrl.$focus = no) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found this being used in a codebase I'm working on. Could you expand on the purpose of this directive?