Skip to content

Instantly share code, notes, and snippets.

@0xBADC0FFEE
Last active December 22, 2015 10:39
Show Gist options
  • Save 0xBADC0FFEE/6460450 to your computer and use it in GitHub Desktop.
Save 0xBADC0FFEE/6460450 to your computer and use it in GitHub Desktop.
app = angular.module('App', []);
app.controller('MenuCtrl', function () {});
app.directive('focusIf', [function () {
return function focusIf(scope, element, attr) {
scope.$watch(attr.focusIf, function (newVal) {
if (newVal) {
scope.$evalAsync(function() {
element[0].focus();
});
}
});
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment