Files
standardnotes-app-web/app/assets/javascripts/directives/functional/autofocus.ts
2020-04-13 08:27:10 -05:00

20 lines
354 B
TypeScript

/* @ngInject */
export function autofocus($timeout: ng.ITimeoutService) {
return {
restrict: 'A',
scope: {
shouldFocus: '='
},
link: function (
$scope: ng.IScope,
$element: JQLite
) {
$timeout(() => {
if (($scope as any).shouldFocus) {
$element[0].focus();
}
});
}
};
}