Open matthias-ccri opened 7 years ago
This would be a breaking change - I'm not necessarily against this, but this could have unintended consequences.
I added a directive to solve the issue temporarily. It simply triggers input change on focus. However typeahead-min-length="0"
implicitly means that typeahead should trigger on focus. Hope Angular-UI team solves this eventually.
app.directive('typeaheadShowOnFocus', function () {
return {
require: 'ngModel',
link: function ($scope, element, attrs, ngModel) {
element.bind('focus', function () {
ngModel.$setViewValue();
$(element).trigger('input');
$(element).trigger('change');
});
}
};
});
Plunker Example : https://plnkr.co/edit/ifaZMhsFaHrQZFOaIA0w?p=preview
I'm experiencing the same issue, that the dropdown doesn't show after clearing the ng-model in code. As soon as I enter anything (and clear via keyboard), the dropdown works again.
The above directive doesn't work for me.
Making sure the value binded to the ng-model is not null is a workaround.
Bug description:
What should happen: When the attribute
typeahead-min-length="0"
is present, focusing on the field should trigger the results dropdown to display. This works only when the ngModel is set toundefined
, but it does not work when it is set tonull
.Plunkr:
https://plnkr.co/edit/dqqcVIGFcVFzvqn2fu4t?p=preview This is the stock typeahead Plunkr, with only one line changed in example.js:
$scope.customSelected = null;
Versions
Angular: 1.5.8 UIBS: 2.2.0 Bootstrap: 3.3.7