angularjs – 使用Angular-ui Bootstrap设置typeahead的选项
发布时间:2020-12-17 17:40:12 所属栏目:安全 来源:网络整理
导读:使用typeahead,我试图设置几个选项,可用作标准的Bootstrap typeahead options 使用下面的代码,我可以通过将其设置为“typeahead-min-length”来设置“minLength”属性,但是对“item”作为“typeahead-items”执行相同操作则不行.有没有不同/更好/标准的方法
使用typeahead,我试图设置几个选项,可用作标准的Bootstrap
typeahead options
使用下面的代码,我可以通过将其设置为“typeahead-min-length”来设置“minLength”属性,但是对“item”作为“typeahead-items”执行相同操作则不行.有没有不同/更好/标准的方法来做到这一点?有没有办法将一系列选项附加到$scope? <div class='container-fluid' ng-controller="TestController"> <input type="text" ng-model="selected" typeahead="foo for foo in foo | filter:$viewValue" typeahead-items='5' typeahead-min-length='3'> <pre>{{selected| json}}</pre> </div> 更新:我试图坚持使用AngularJS,而不是使用jQuery 这是我的控制器: myAppModule.controller('TestController',function($http,$scope) { $scope.selected = undefined; $http.get('data/sample.json') .then(function(results){ $scope.foo = results.data; }); }); 解决方法
为什么不使用JS方式初始化typeahead:
$('input.typeahead').typeahead({ source: array_of_value_here,minLength: 1,items: 5,// your option values ... }); 编辑: 我看,AngularJS方式,你可以使用limitTo: <input type="text" ng-model="selected" typeahead="foo for foo in foo | filter:$viewValue | limitTo:5" typeahead-min-length='3'> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读