javascript - Angular uib-typeahead 无法正常工作

标签 javascript html angularjs angular-ui-bootstrap angular-ui-typeahead

我研究并浏览了其他解决方案,但我似乎无法让它继续工作。

我的主要问题是 uib-typeahead 似乎根本不起作用,无论是指向返回值还是指向函数(我将在下面提供示例)。

为此,我正在使用/继承 Angular.UI.Bootstrap (v2.5.0)。

我的 HTML 调用(尝试使用异步和不使用异步)是:

 <input type="text" ng-model="selected" uib-typeahead="r.ResourceValueId as r.Value for r in ResourceValues | filter:$viewValue" class="form-control">



<input type="text" ng-model="asyncSelected" placeholder="Resources" uib-typeahead="item.ResourceValueId as item.Value for item in getResourceValuesSearch($viewValue)" 
typeahead-loading="loadingResources" typeahead-no-results="noResults" class="form-control">
<i ng-show="loadingResources" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found</div>

两个输入都没有出现下拉菜单,并且已填充 ResourceValues(使用正常的“选择”进行测试)。对于异步,它根本不调用 getResourceValuesSearch() 函数。

更新:我同时包含 ngSanitize 和 ngAnimate 并在模块上运行。所以这个问题似乎与 angular-ui-typeahead 直接相关,因为其他一切似乎都工作得很好。

最佳答案

编写一个调用 Api 的服务并从中获取 promise 。在您的函数中使用服务并返回数据。

关于javascript - Angular uib-typeahead 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43621602/

相关文章:

javascript - 将预加载器添加到 div 标签

javascript - 小部件屏幕上的服务/模块之间的通信

javascript - 通过 2 个变量的可见性 div,不同的开/关

javascript - ng-style 的变量未更新到 View

在原型(prototype)上定义的 Javascript 属性

javascript - js中同步管理缓存

javascript - 从 JavaScript 对象中的键查找最高值

html - ~ 选择器在 Android 中不工作

javascript - 从视口(viewport)中心展开 div

angularjs - 调试中断注入(inject)的最佳方法是什么(由于缩小)?