bootstrap
bootstrap copied to clipboard
Typeahead throws exception on exact match
Bug description:
When using typeahead with attributes typeahead-select-on-exact="true" and typeahead-show-hint="true" exception is thrown when exact match happens: Cannot read property 'label' of undefined
Link to minimally-working plunker that reproduces the issue:
https://plnkr.co/edit/HrKQIcOy0XjN9BBosdRS?p=preview
Steps to reproduce the issue:
- Open DevTools
- Type "Alabama" in input field
- Error appears in log.
Same problem here...
I'm looking for a work around in the meanwhile.
I have changed the getMatchesAsync function, that was the easiest way that I have found to make it work.
if (showHint) {
if (scope.matches.length > 0)
{
var firstLabel = scope.matches[0].label;
if (angular.isString(inputValue) &&
inputValue.length > 0 &&
firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) {
hintInputElem.val(inputValue + firstLabel.slice(inputValue.length));
} else {
hintInputElem.val('');
}
}
}