diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 8547c6f587..0c6699158a 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -222,7 +222,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap resetMatches(); //return focus to the input element if a mach was selected via a mouse click event - element[0].focus(); + // use timeout to avoid $rootScope:inprog error + $timeout(function() { element[0].focus(); }, 0, false); }; //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27) @@ -346,4 +347,4 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap return function(matchItem, query) { return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem; }; - }); \ No newline at end of file + });