Last active
February 10, 2017 19:57
-
-
Save aeinbu/39913d59aeb4d1760b8dab700cc34169 to your computer and use it in GitHub Desktop.
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
const angular = require("angular"); | |
angular | |
.module("modulename") | |
.directive('attachFocusFunction', function($parse) { | |
return { | |
scope: false, | |
link(scope, element, attributes) { | |
let expr = $parse(attributes.attachFocusFunction); | |
if(!expr.assign){ | |
throw "Please provide a valid lhs expression for the attachFocusFunction"; | |
} | |
expr.assign(scope, function() { | |
element[0].focus(); | |
}); | |
} | |
} | |
}); |
Author
aeinbu
commented
Jan 4, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment