contacts/js/components/focus_directive.js

20 lines
443 B
JavaScript
Raw Normal View History

2016-03-02 09:35:35 +00:00
app.directive('focusExpression', function ($timeout) {
return {
restrict: 'A',
link: {
post: function postLink(scope, element, attrs) {
scope.$watch(attrs.focusExpression, function (value) {
if (attrs.focusExpression) {
if (scope.$eval(attrs.focusExpression)) {
$timeout(function () {
element[0].focus();
}, 100); //need some delay to work with ng-disabled
}
}
});
}
}
};
});