mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-27 06:54:01 +00:00
fix(docs): migrate from $defer to $timeout
This commit is contained in:
parent
f16150d5f1
commit
d9ff5fd432
1 changed files with 5 additions and 3 deletions
|
|
@ -5,16 +5,18 @@ var docsApp = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
docsApp.directive.focused = function($defer) {
|
docsApp.directive.focused = function($timeout) {
|
||||||
return function(scope, element, attrs) {
|
return function(scope, element, attrs) {
|
||||||
element[0].focus();
|
element[0].focus();
|
||||||
element.bind('focus', function() {
|
element.bind('focus', function() {
|
||||||
scope.$apply(attrs.focused + '=true');
|
scope.$apply(attrs.focused + '=true');
|
||||||
});
|
});
|
||||||
element.bind('blur', function() {
|
element.bind('blur', function() {
|
||||||
// have to use defer, so that we close the drop-down after the user clicks,
|
// have to use $timeout, so that we close the drop-down after the user clicks,
|
||||||
// otherwise when the user clicks we process the closing before we process the click.
|
// otherwise when the user clicks we process the closing before we process the click.
|
||||||
$defer(attrs.focused + '=false');
|
$timeout(function() {
|
||||||
|
scope.$eval(attrs.focused + '=false');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
scope.$eval(attrs.focused + '=true')
|
scope.$eval(attrs.focused + '=true')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue