-
Notifications
You must be signed in to change notification settings - Fork 6.7k
error on typeahead #2999
Comments
http://plnkr.co/edit/4hC1F6dKfGS3rRXqLtiN?p=preview |
I had this error as well using another library to help with with fuzzy search. I needed to make a copy of the array from the response and have the other library work on new array and return those values to typeahead. The typeahead function that checks $viewValue isn't dealing with the original array after a certain point, so "matches" becomes undefined and if the results are empty it can't reference the original array to check the length property. A quick fix was to just check if matches are defined and then the length.
Following is where I made the change in case it will help someone in the future. |
It does not happen every time. I have the feeling there is a issue of timing. Using your plunkr, if I quickly use the typeahead the error will show up. If I wait long enough, the error will not happen. That being said, the fix seems obvious and harmless. thanks @unkleara |
- resolves property length of undefined error by checking value first angular-ui#2999 Fixes angular-ui#2999 Closes angular-ui#3178
if (matches && matches.length > 0) prevents the undefined error, but first time, the matched dropdown does not show up anyway. Please tell me what needs to be done. As above indicated, from second time onwards, everything works fine. |
sorry, in the code
brandChainNames was not intialized. Now it is working. It is not a bug in bootstrap, it is bug on the coder's part. |
in the last line (in getMatchesAsync):
var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
if (onCurrentRequest && hasFocus) {
if (matches.length > 0) {
an error is thrown that matches.length is not defined.
on the next attempt - it works ok.
The text was updated successfully, but these errors were encountered: