angularjs – 焦点打开列表

前端之家收集整理的这篇文章主要介绍了angularjs – 焦点打开列表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用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');
            });
        }
    };

});

所以在视图中我设置了我的输入:

<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相关文章