blob: 3e60d1705d55a9850cb4290455697cba992adf5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
angular.module('contactsApp')
.directive('selectExpression', function ($timeout) {
return {
restrict: 'A',
link: {
post: function postLink(scope, element, attrs) {
scope.$watch(attrs.selectExpression, function () {
if (attrs.selectExpression) {
if (scope.$eval(attrs.selectExpression)) {
$timeout(function () {
if (element.is('input')) {
element.select();
} else {
element.find('input').select();
}
}, 100); //need some delay to work with ng-disabled
}
}
});
}
}
};
});
|