Solvedmaterial md-autocomplete: Cannot read property 'then' of undefined
✔️Accepted Answer
That's a f ridiculous issue: isPromise = items && items.then;
It makes me reconsider the experience of people I'm trusting on.
Other Answers:
I had the same error caused by following query function:
function querySearch(searchText) { if (!searchText) return; ... }
The fix was to return an empty array in case of an empty searchText.
This issue is first in google ( "angular autocomplete Cannot read property 'then' of undefined" ). I think it may help some people:
This error occures also when you use function that does not exist, like:
md-items="item in notExistingFunction(query)"
and there is no other information in error stack (angular digest.. and then 'cannot read prop...').
https://material.angularjs.org/latest/api/directive/mdAutocomplete
- md-items expression
An expression in the format of item in items to iterate over matches for your search.
!!items.then - items must be defined, as every variable over which you can iterate
Checking if items exists would be an issue - waste of CPU (I'm not sure about it) and code not according to documentation.
In version 1.0.7 I get this error when typing in
md-autocomplete
:The error seems NOT to happen in a previous version. More detailed explanation is on StackOverflow.