Pregunta

I'm trying to use Angular-UI typeahead along with some data from my firebase.

The data looks something like this:

Data:{ 
"-JL8IPEAs0vLSt4DJ4V9": { "name": "Something" }, 
"-JL8IbggYn3O8jkWoPmv": { "name": "Something Else" } 
}

My HTML looks like this:

<input type="text" ng-model="answer.help" typeahead="label for (key , value) in object | limitTo:8">

Basically my problem is that I can't figure out how to do the select part in typeahead properly with my current data structure.

These ressources were helpful: https://docs.angularjs.org/api/ng/directive/select http://angular-ui.github.io/bootstrap/#/typeahead

But I couldn't really figure out how to get it working. I'm guessing it's relatively simple, but I couldn't find anywhere that could help me figure it out. I've tried a lot of different combinations, but since the typeahead part does give much useful feedback when i'm doing it wrong, I've found myself stuck.

Any help would be greatly appreciated. Thanks.

¿Fue útil?

Solución

It looks like Angular-UI's typeahead doesn't support the (key, value) syntax that Angular's select directive supports. But You should be able to convert your data structure into an array using angularfire's orderByPriority. Then you can do something like this (assuming records is an array):

<input type="text" typeahead="record.name for record in records | limitTo:8">

http://plnkr.co/edit/g4PMSPmOU0XkrdVwAAYa?p=preview

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top