gpt4 book ai didi

angularjs - 在焦点上打开列表

转载 作者:行者123 更新时间:2023-12-04 19:06:00 25 4
gpt4 key购买 nike

我使用 angular bootstrap ui (typeahead) 尝试在输入焦点时显示我的客户列表,如下所示:

lima3app.directive('typeaheadOpenOnFocus', function() {
return {
require: ['ngModel'],
link: function(scope, element, attr, ctrls) {
element.bind('focus', function() {
ctrls.$setViewValue('');
console.log('customer.customer');
});
}
};

});

所以在 View 中我设置了我的输入:
<input type="text" class="form-content req" id="form-customer"
name="formcustomer"
typeahead="customer as customer.customer for customer in customerList | filter:{customer:$viewValue}"
typeahead-on-select="onCustomerSelect($item)"
typeahead-append-to-body="true"
typeahead-open-on-focus

ng-model="customer.customer"
focus="true"
required="required">

但是代码,不起作用。有没有办法做到这一点?

最佳答案

感谢@HenryNeo 找到了 UI Bootstrap 接受的正确属性。以下代码对我有用,适用于 angular-ui Bootstrap 1.3.3。

使用 uib-typeahead启用下拉菜单和 typeahead-min-length (不带 uib-)启用 minLength属性。

<input type="text" typeahead-min-length="0" uib-typeahead="t for t in timeZoneList">

关于angularjs - 在焦点上打开列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24541355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com