场景:前端有AngularJS,后端有Django。我曾经watson
在数据库中搜索产品。我正在尝试为“搜索”(输入type =“ text”)实现autocomplete_light。
$('#searchText').yourlabsAutocomplete({
url: '{% url "get_search_results" %}', // this is where watson is getting used
choiceSelector: 'a',
minimumCharacters: 4,
}).input.bind('selectChoice', function(e, choice, autocomplete) {
window.location.href = choice.attr('href');
});
预期的行为:上面的代码可以正常工作并product_json
在我在搜索文本字段中键入内容时显示,但我希望它以完美呈现的html格式显示。我想知道如何在这里使用AngularJS呈现此JSON并按href
选择提供。
我在下面的链接中找到了autocomplete.js的文档
http://django-autocomplete-light.readthedocs.org/en/stable-2.xx/_static/autocomplete.html
如果您有自定义搜索脚本,则可以使用Angular进行调用并创建自定义TextAhead
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句