2017-02-07 13:34:26 +00:00
|
|
|
import {module} from '../module';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2017-02-08 13:45:27 +00:00
|
|
|
// Sets the focus and selects the text on the input.
|
|
|
|
|
2017-01-31 13:13:06 +00:00
|
|
|
export function directive() {
|
|
|
|
return {
|
|
|
|
restrict: 'A',
|
|
|
|
link: function($scope, $element, $attrs) {
|
2017-02-08 13:45:27 +00:00
|
|
|
$scope.$watch($attrs.vnFocus, function(value) {
|
|
|
|
if ($element[0].getElementsByTagName("INPUT")[0])
|
|
|
|
$element[0].getElementsByTagName("INPUT")[0].focus();
|
|
|
|
if ($element[0].getElementsByTagName("TEXTAREA")[0])
|
|
|
|
$element[0].getElementsByTagName("TEXTAREA")[0].focus();
|
|
|
|
});
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
module.directive('vnFocus', directive);
|