1
試圖顯示來自與ES詞組建議者的建議對象的選項陣列使用AngularJS第一選項10顯示搜索建議,但難倒....如何從Elasticsearch短語建議者與AngularJS
此輸出第一元素在選項數組中:
{{suggestions.options[0].text}}
該文本是實際的建議。從開發控制檯
輸出在Chrome:
suggest: {,…}
phraseSuggestion: [{text: "pytho", offset: 0, length: 5, options: [{text: "python", score: 0.12858662}]}]
0: {text: "pytho", offset: 0, length: 5, options: [{text: "python", score: 0.12858662}]}
length: 5
offset: 0
options: [{text: "python", score: 0.12858662}]
0: {text: "python", score: 0.12858662}
text: "pytho"
如何訪問:
options: [{text: "python", score: 0.12858662}]
在我的HTML模板,並顯示數組中的第5至10個選項。
我聽不懂,你可以用{{suggestions.options [0] .text}}來訪問它' –
@Michelem是的我明白,我想要做的是列出5 - 10選項,而不是1,這是所有代碼顯示 – user3125823