$timeout
instead of setTimeout
JS-05622063
2064 self.ignoreFocus = true;
2065 self.$control_input[0].focus();
2066 window.setTimeout(function() {2067 self.ignoreFocus = false;
2068 self.onFocus();
2069 }, 0);
1549 if (self.settings.splitOn) {
1550
1551 // Wait for pasted text to be recognized in value
1552 setTimeout(function() {1553 var pastedText = self.$control_input.val();1554 if(!pastedText.match(self.settings.splitOn)){ return }1555 1556 var splitInput = $.trim(pastedText).split(self.settings.splitOn);1557 for (var i = 0, n = splitInput.length; i < n; i++) {1558 self.createItem(splitInput[i]);1559 }1560 }, 0);1561 }
1562 },
1563
1514 } else {
1515 // give control focus
1516 if (!defaultPrevented) {
1517 window.setTimeout(function() {1518 self.focus();
1519 }, 0);
1520 }
889 var self = this;
890 var args = arguments;
891 window.clearTimeout(timeout);
892 timeout = window.setTimeout(function() { 893 fn.apply(self, args);
894 }, delay);
895 };
1427
1428 self.ignoreFocus = true;
1429 self.$control_input[0].focus();
1430 window.setTimeout(function() {1431 self.ignoreFocus = false;
1432 self.onFocus();
1433 }, 0);
Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout.
Rule based on Angular 1.x
// invalid
setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
// invalid
window.setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
// invalid
$window.setTimeout(function() {
// ...
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
// valid
$timeout(function() {
// ...
}, 1000)