Fix: The new focusing directive wanted exclusive scope and it conflicted at times. Fixed.

This commit is contained in:
tanshu committed 2015-01-11 12:28:27 +05:30
1 parent 948b45b2ce
commit 9c70286258
2 files changed
+10 -11

No files matched your search

+8 -9
View File
@@ -378,19 +378,18 @@ overlordDirective.directive('fileUpload', function () {
};
});
overlordDirective.directive('focusOn', ['$timeout', function ($timeout) {
overlordDirective.directive('focusOn', ['$timeout', '$parse', function ($timeout, $parse) {
return {
restrict: 'A',
scope: {
focusOn: '='
},
link: function (scope, element, attrs) {
scope.$watch('focusOn', function (value) {
scope.$watch(attrs.focusOn, function (value) {
if (value === true) {
//$timeout(function () {
element[0].focus();
scope.focusOn = false;
//});
var getter = $parse(attrs.focusOn);
var setter = getter.assign;
setter(scope, false);
$timeout(function () {
element[0].focus();
});
}
});
}