0

Problem code there.

The problem is when I type the new symbol, autocompleteed drop down list do not appear. It only appear if I delete character. How to fix it?

how to reproduce - type 3-5 characters, then delete last one.

silent_coder
  • 6,222
  • 14
  • 47
  • 91

1 Answers1

1

Not sure what you real use-case is but if you just want to provide a fixed list of matches based on entered criteria you can do so very easily by simply providing a function call in the typeahead expression:

typeahead="state for state in genData($viewValue)"

provided that the genData is a function exposed on a scope:

$scope.genData = function(key){
    return [key+ "abcd", key+ "111", key+ "FFc32", key+"777"];
};

Working plunk here: http://plnkr.co/edit/6SIGGS?p=preview

Also, please note that your plunk is using rather old version of angular-ui/bootstrap (0.4.0, while the latest is 0.6.0).

pkozlowski.opensource
  • 117,202
  • 60
  • 326
  • 286
  • Check my plunk again. I update it a little. The problem with your approach is dropdown values do not filter somehow, and even if you type '777777' you still will see the value like 'abcd'. – silent_coder Sep 25 '13 at 16:47
  • @silent_coder I'm still _not_ super clear about what are you trying to do in reality but if we also want to filter a generated array you can inject a filter into a controller. See the updated plunk: – pkozlowski.opensource Sep 25 '13 at 16:52
  • Oh, that's works much better. My example it's just the stub, in real project data not generated of course, but requested from the server. But what is the filterFilter? – silent_coder Sep 25 '13 at 17:01
  • @silent_coder this is just a standard AngularJS filter (http://docs.angularjs.org/api/ng.filter:filter) used from JavaScript. Usually people are injecting the $filter service as shown in the documentation but this is just alternative syntax. – pkozlowski.opensource Sep 25 '13 at 17:04
  • @silent_coder one more thing - if you are looking for the integration with the server side, check this: http://stackoverflow.com/q/15930339/1418796 – pkozlowski.opensource Sep 25 '13 at 17:05