- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 Angular UI's typeahead结合 Web Api 加载搜索结果。我的 Angular 是 1.2.2 版,bootstrap 是 3.1.0 版。我应该提到我也在使用 typescript 。
当我在搜索框中输入内容时,我希望带有建议的下拉菜单会从输入中掉下来。当我检查控制台时,我看到了我返回的数据,问题是没有显示它的下拉菜单。
这是我的 HTML + Angular Directive(指令):
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" ng-model="selected"
data-typeahead="searchResult as searchResult for searchResult in search($viewValue) | filter:$viewValue" >
<div class="input-group-btn">
<button class="btn btn-default" type="submit" ng-click="search(Text)"><i class=" glyphicon glyphicon-search"></i></button>
</div>
</div>
这是位于我的 Controller 中的 js 函数:
$scope.search = function (criteria) {
controller.dataService.search($scope.employeeId, criteria, function (data) {
$scope.searchResult = data;
});
这是我的数据服务中的搜索功能。
export interface ICommonDataService extends IBaseDataService {
search(employeeId: string, criteria: string, successCallback: (data: SearchResult) => any);
}
dataservice.ts 信息:
export class DataServicBase {
public httpService: ng.IHttpService;
public serviceBase = '/services/api';
public static $inject = [
'$http'
];
constructor($http: any) {
this.httpService = $http;
}
}
export class CommonDataService extends DataServicBase implements ICommonDataService {
public serviceUrl = this.serviceBase + '/common';
search(employeeId: string, criteria: string, successCallback: (data: SearchResult) => any) {
this.httpService.get(this.serviceUrl + '/' + employeeId + '/search/' + criteria)
.success(function (data) {
successCallback(data);
});
}
}
这是 SearchResult 的样子:
// Class
export class SearchResult {
// Constructor
constructor(
public Employees: Employee[],
public Filters: Employee[],
public Projects: Project[]
) {
}
}
我得到的错误是这样的:
Error: matches is undefined
.link/getMatchesAsync/<@https://web.plank.local/Scripts/ui-bootstrap-tpls-0.10.0.js:3186
qFactory/defer/deferred.promise.then/wrappedCallback@https://web.plank.local/scripts/angular.js:10655
qFactory/defer/deferred.promise.then/wrappedCallback@https://web.plank.local/scripts/angular.js:10655
qFactory/ref/<.then/<@https://web.plank.local/scripts/angular.js:10741
$RootScopeProvider/this.$get</Scope.prototype.$eval@https://web.plank.local/scripts/angular.js:11634
$RootScopeProvider/this.$get</Scope.prototype.$digest@https://web.plank.local/scripts/angular.js:11479
$RootScopeProvider/this.$get</Scope.prototype.$apply@https://web.plank.local/scripts/angular.js:11740
textInputType/listener@https://web.plank.local/scripts/angular.js:15739
jQuery.event.dispatch@https://web.plank.local/scripts/jquery-2.1.0.js:4371
jQuery.event.add/elemData.handle@https://web.plank.local/scripts/jquery-2.1.0.js:4057
aM@https://cdn.qbaka.net/reporting.js:78
https://web.plank.local/scripts/angular.js
Line 9159
最佳答案
主要问题是您希望预先输入的数据列表不是列表(或未填充)。在我看来, Controller 中的函数 search 应该返回数据,而这只是一个 promise 。您可以尝试 返回 数据,并可以添加 limitToFilter 使其更健壮。而不是将它放在共享的 scope.searchResult 中,而这根本不会被您提前输入。
关于javascript - Angular UI typeahead 下拉菜单不出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21982144/
在我的 html 页面中,我尝试添加 Typeahead 以进行自动完成,但我无法解决与 TypeError 和 ReferenceError 相关的问题。 我在 CodePen 上尝试了一个示例,工
我已经使用 npm 安装了 typeahead.js。根据我的阅读,这包括预输入和猎犬。 然后我在我的模块中需要 jquery 之后需要它。 但现在当我打电话 new Bloodhound() Blo
我正在尝试使用Twitter提前输入,但遇到了问题。我不知道如何提前将字符串传递给服务器。是通过GET参数吗?如果是这样,该参数的名称是什么? 最佳答案 通过GET参数最简单,您可以选择所需的任何参数
看起来 CSS 不适用于我的 Typeahead。 我正在尝试重现可滚动下拉菜单,例如 https://twitter.github.io/typeahead.js/examples 这是我的代码:
我正在这样设置 typeahead: $this.typeahead({ prefetch: $this.data('url-prefetch'),
我有一个 Typeahead 实例拉入一个列出机场的远程 JSON 对象,我需要按“位置组”将它们分组到建议中,如下图所示: ...这里是如何格式化 JSON 的示例: { "locations
作为标题,我想问:“是否可以限制预先输入显示的建议?” 例如,我有 3 个数据集,每个数据集有 10000 个结果(来自查询)。主题以字符 t 开头大约有 3000 个结果或可能更多。 如果我输入 t
我想实现的功能是,如果我点击一个 DOM 元素,它会自动填充其中包含指定值的预先输入,它应该为此触发 typeahead:selected。 我发现了很多与之相关的查询,答案是 jQuery#type
首先,请检查:http://ws.luyencong.net/data/search/query.php?do=advanced 您可以将该 JSON 的所有内容粘贴到此处:http://pro.js
我一直在尝试结合几个功能 in typeahead plugin特别是多数据集 + 空 + 默认建议。到目前为止没有运气,希望有人可以帮助 现在,为了使其工作,它是多个数据集之间的选择---或---空
我正在尝试将预输入结果放入页面上的特定 div 中。我获得了 JSON 回调数据,但我不知道如何使用它来填充特定的 div。 process 函数的唯一作用是在搜索字段下方列出结果,无论其长度如何。
正如在 screenshot - 使用 typeahead 时如何禁用自动填充? 谢谢。 附注: 使用的浏览器是 Chrome 版本 47.0.2526.106(64 位) 最佳答案 添加 autoc
正如在 screenshot - 使用 typeahead 时如何禁用自动填充? 谢谢。 附注: 使用的浏览器是 Chrome 版本 47.0.2526.106(64 位) 最佳答案 添加 autoc
我使用的是 0.11.1 版的 Twitter Typeahead。现在我正试图让远程工作正常,但不知何故我认为我的行为很奇怪。 这是使用本地数组的工作代码: var localArray = [{"
我试过在 web 应用程序中应用 twitters typeahead 插件。我使用 typeahead 插件初始化了许多 typeahead 输入字段,这似乎以某种方式起作用。该插件栩栩如生。然而,
所以我使用Materialziecss和第三方库进行标签输入 Materializecss:http://materializecss.com/ Materialize 标签库:http://henr
我想用 Typeahead JS 做一个简单的自动完成但我不能让它工作。我按照手册中的说明进行操作,但我不确定我在这里做错了什么。我无法从 json 文件中获取正确的值。它是一个带有对象的数组,我只想
我有一个 Angular uib-typeahead。这是我创建的 plunkr 的链接。 https://plnkr.co/edit/8XwhSXsZlyd0oKSljS9t?p=preview .
我实际上想发送我选择的主题(一个包含许多变量的 json 对象),而不是存储在 topicsPopulate 中的字符串(主题名称)。Topics 是一个主题数组,一个主题看起来像这样, {
我正在尝试使用带有 react-bootstrap-typeahead 的旧 jQuery typeahead 来复制搜索字段。它查询使用多个异步数据源,并显示按这些数据源的返回分组的结果。 例如,如
我是一名优秀的程序员,十分优秀!