diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 5fd8155b5f..8486436806 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -462,6 +462,18 @@ describe('typeahead tests', function () { expect(element).toBeOpenWithActive(2, 0); }); + + it('issue #1238 - allow names like "query" to be used inside "in" expressions ', function () { + + $scope.query = function() { + return ['foo', 'bar']; + }; + + var element = prepareInputEl("
"); + changeInputValueTo(element, 'bar'); + + expect(element).toBeOpenWithActive(2, 0); + }); }); describe('input formatting', function () { diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index ab52005c1f..d886886165 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -97,7 +97,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap var locals = {$viewValue: inputValue}; isLoadingSetter(originalScope, true); - $q.when(parserResult.source(scope, locals)).then(function(matches) { + $q.when(parserResult.source(originalScope, locals)).then(function(matches) { //it might happen that several async queries were in progress if a user were typing fast //but we are interested only in responses that correspond to the current view value