Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.