Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
fix(typehead): reset matches to hide popover
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Perez authored and mgcrea committed Apr 9, 2014
1 parent 1285a72 commit 82e03ef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ angular.module('mgcrea.ngStrap.typeahead', ['mgcrea.ngStrap.tooltip', 'mgcrea.ng
var parentScope = config.scope;
var scope = $typeahead.$scope;

scope.$matches = [];
scope.$activeIndex = 0;
scope.$resetMatches = function(){
scope.$matches = [];
scope.$activeIndex = 0;
};
scope.$resetMatches();

scope.$activate = function(index) {
scope.$$postDigest(function() {
Expand Down Expand Up @@ -74,9 +77,7 @@ angular.module('mgcrea.ngStrap.typeahead', ['mgcrea.ngStrap.tooltip', 'mgcrea.ng
controller.$render();
if(parentScope) parentScope.$digest();
}
if(options.trigger === 'focus') element[0].blur();
else if($typeahead.$isShown) $typeahead.hide();
scope.$activeIndex = 0;
scope.$resetMatches();
// Emit event
scope.$emit('$typeahead.select', value, index);
};
Expand Down

0 comments on commit 82e03ef

Please sign in to comment.