Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit fd21214

Browse files
fix(typeahead): evaluate matches source against a correct scope
Closes #1238
1 parent 968e540 commit fd21214

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/typeahead/test/typeahead.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,18 @@ describe('typeahead tests', function () {
462462

463463
expect(element).toBeOpenWithActive(2, 0);
464464
});
465+
466+
it('issue #1238 - allow names like "query" to be used inside "in" expressions ', function () {
467+
468+
$scope.query = function() {
469+
return ['foo', 'bar'];
470+
};
471+
472+
var element = prepareInputEl("<div><input ng-model='result' typeahead='item for item in query($viewValue)'></div>");
473+
changeInputValueTo(element, 'bar');
474+
475+
expect(element).toBeOpenWithActive(2, 0);
476+
});
465477
});
466478

467479
describe('input formatting', function () {

src/typeahead/typeahead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
9797

9898
var locals = {$viewValue: inputValue};
9999
isLoadingSetter(originalScope, true);
100-
$q.when(parserResult.source(scope, locals)).then(function(matches) {
100+
$q.when(parserResult.source(originalScope, locals)).then(function(matches) {
101101

102102
//it might happen that several async queries were in progress if a user were typing fast
103103
//but we are interested only in responses that correspond to the current view value

0 commit comments

Comments
 (0)