如何在Angular UI typeahead中正确使用select和firebase数据

How to use select properly with firebase data in Angular UI typeahead

本文关键字:select 数据 firebase Angular UI typeahead      更新时间:2023-09-26

我正在尝试使用Angular UI typeahead以及来自firebase的一些数据。

数据看起来像这样:

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

我的HTML如下所示:

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

基本上,我的问题是,我无法弄清楚如何用我当前的数据结构正确地进行排版中的选择部分。

这些资源非常有用:https://docs.angularjs.org/api/ng/directive/selecthttp://angular-ui.github.io/bootstrap/#/typeahead

但我真的不知道如何让它发挥作用。我猜这相对简单,但我找不到任何地方可以帮助我弄清楚。我试过很多不同的组合,但由于打字部分在我做错的时候确实会给出很多有用的反馈,我发现自己陷入了困境。

如有任何帮助,我们将不胜感激。谢谢

Angular UI的typeahead似乎不支持Angular的select指令支持的(key,value)语法。但是您应该能够使用angularfire的orderByPriority将数据结构转换为数组。然后你可以做这样的事情(假设records是一个数组):
<input type="text" typeahead="record.name for record in records | limitTo:8">

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