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

Commit

Permalink
fix(typeahead): evaluate matches source against a correct scope
Browse files Browse the repository at this point in the history
Closes #1238
  • Loading branch information
pkozlowski-opensource committed Nov 9, 2013
1 parent 968e540 commit fd21214
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/typeahead/test/typeahead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div><input ng-model='result' typeahead='item for item in query($viewValue)'></div>");
changeInputValueTo(element, 'bar');

expect(element).toBeOpenWithActive(2, 0);
});
});

describe('input formatting', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd21214

Please sign in to comment.