import {module} from '../module'; /** * Sets the focus and selects the text on the input. */ export function directive() { return { restrict: 'A', link: function($scope, $element, $attrs) { var input = $element[0].parentNode.querySelector('input, textarea'); if(!input) throw new Error(`vnFocus: Can't find an input element`); input.focus(); input.select(); } }; } module.directive('vnFocus', directive);