Skip to content

Instantly share code, notes, and snippets.

@wallin
Created October 11, 2013 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallin/6934406 to your computer and use it in GitHub Desktop.
Save wallin/6934406 to your computer and use it in GitHub Desktop.
Angular JS directive that adds $focus attribute to form elements
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)
]
@ionox0
Copy link

ionox0 commented Jan 18, 2016

Found this being used in a codebase I'm working on. Could you expand on the purpose of this directive?

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