Files
standardnotes-app-web/app/assets/javascripts/app/services/directives/functional/autofocus.js
2018-01-17 12:04:29 -06:00

18 lines
364 B
JavaScript

angular
.module('app.frontend')
.directive('snAutofocus', ['$timeout', function($timeout) {
return {
restrict: 'A',
scope: {
shouldFocus: "="
},
link : function($scope, $element) {
$timeout(function() {
if($scope.shouldFocus) {
$element[0].focus();
}
});
}
}
}]);