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

add support for changing typeaheadMinLength #5363

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap
if (!minLength && minLength !== 0) {
minLength = 1;
}

originalScope.$watch(attrs.typeaheadMinLength, function (newVal) {
if (!newVal && newVal !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just make a ternary, i.e.

minLength = !newVal && newVal !== 0 ? 1 : newVal;

minLength = 1;
} else {
minLength = newVal;
}
});

//minimal wait time after last character typed before typeahead kicks-in
var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;

Expand Down