Skip to content

Instantly share code, notes, and snippets.

@oddlyfunctional
Created April 19, 2016 22:38
Show Gist options
  • Save oddlyfunctional/055b1e015c0a94bbf2993de19cce20ec to your computer and use it in GitHub Desktop.
Save oddlyfunctional/055b1e015c0a94bbf2993de19cce20ec to your computer and use it in GitHub Desktop.
focusOn = ($timeout) ->
link = (scope, element, attrs) ->
scope.$watch attrs.focusOn, (newValue) ->
$timeout(-> element.focus()) if !!newValue
restrict: 'A'
link: link
focusOn.$inject = ['$timeout']
angular
.module('app.lessonPlan')
.directive('focusOn', focusOn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment