diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js
index e2c3eebf64..746a5a2854 100644
--- a/src/typeahead/test/typeahead.spec.js
+++ b/src/typeahead/test/typeahead.spec.js
@@ -200,7 +200,7 @@ describe('typeahead tests', function () {
};
var findDropDown = function(element) {
- return element.find('div.dropdown');
+ return element.find('ul.typeahead');
};
var findMatches = function(element) {
@@ -222,7 +222,7 @@ describe('typeahead tests', function () {
this.message = function() {
return "Expected '" + angular.mock.dump(this.actual) + "' to be closed.";
};
- return !typeaheadEl.hasClass('open') && findMatches(this.actual).length === 0;
+ return typeaheadEl.css('display')==='none' && findMatches(this.actual).length === 0;
}, toBeOpenWithActive: function(noOfMatches, activeIdx) {
@@ -232,7 +232,7 @@ describe('typeahead tests', function () {
this.message = function() {
return "Expected '" + angular.mock.dump(this.actual) + "' to be opened.";
};
- return typeaheadEl.hasClass('open') && liEls.length === noOfMatches && $(liEls[activeIdx]).hasClass('active');
+ return typeaheadEl.css('display')==='block' && liEls.length === noOfMatches && $(liEls[activeIdx]).hasClass('active');
}
});
});
@@ -391,12 +391,11 @@ describe('typeahead tests', function () {
var inputEl = findInput(element);
changeInputValueTo(element, 'b');
- var dropdown = findDropDown(element);
$document.find('body').click();
$scope.$digest();
- expect(dropdown).not.toHaveClass('open');
+ expect(element).toBeClosed();
});
});
diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js
index 901f4ccbaa..6bb4ad3eaf 100644
--- a/src/typeahead/typeahead.js
+++ b/src/typeahead/typeahead.js
@@ -1,4 +1,4 @@
-angular.module('ui.bootstrap.typeahead', [])
+angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
/**
* A helper service that can parse typeahead's syntax (string provided by users)
@@ -29,8 +29,7 @@ angular.module('ui.bootstrap.typeahead', [])
};
}])
- //options - min length
- .directive('typeahead', ['$compile', '$parse', '$q', '$document', 'typeaheadParser', function ($compile, $parse, $q, $document, typeaheadParser) {
+ .directive('typeahead', ['$compile', '$parse', '$q', '$document', '$position', 'typeaheadParser', function ($compile, $parse, $q, $document, $position, typeaheadParser) {
var HOT_KEYS = [9, 13, 27, 38, 40];
@@ -51,6 +50,16 @@ angular.module('ui.bootstrap.typeahead', [])
var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
+ //pop-up element used to display matches
+ var popUpEl = angular.element(
+ "