javascript - AngularJS:为什么我不能使用箭头键从文本框中选择自动完成列表?

标签 javascript jquery angularjs twitter-bootstrap autocomplete

我正在关注在 AngularJS API 文档中找到的“typeahead”代码:http://angular-ui.github.io/bootstrap/

我可以通过按回车键用第一个选项填充文本框,但由于某种原因,我无法使用箭头键(向上和向下)从自动完成列表中选择任何项目,但在他们的示例中, 我可以。

这可能是什么问题?

** 注意,这是一个 Express 项目,我使用的是 Jade 引擎。

头文件

link(rel='stylesheet', href='/css/bootstrap.css')
script(src='/js/jquery-2.1.1.min.js')
script(src='/js/angular.min.js')
script(src='/js/bootstrap.min.js')
script(src='/js/ui-bootstrap-tpls-0.11.0.min.js')
script(src='/js/index.js')

index.html 中的部分代码

<div ng-controller="TypeaheadCtrl" class="col-md-5 ng-scope">
    <pre class="ng-binding">Model {{selected}}</pre>
    <input type="text" ng-model="selected" placeholder="item name" typeahead="item for item in items | filter:$viewValue | limitTo:8" class="form-control" >
</div>

索引.js

var App = angular.module('myApp', ['ui.bootstrap']);
function TypeaheadCtrl( $scope, $http ) {
    $scope.selected = undefined;
    $scope.items = ['Chicken', 'Corn', 'Ice Cream', 'Cereal'];
}

problem

经过更多尝试后,我发现我的浏览器还有另一个自动完成功能。可能是 chrome 自动填充?也许我的上下正在用于此而不是用于我的网络应用程序?如果是这样,您将如何通过代码禁用它,以便我可以仅在该页面上将其用于 Angular 的自动完成?

problem2

最佳答案

尝试设置 autocomplete="off"<form><input>水平。

autocomplete 的文档可以在 Mozilla's <input> section 中找到

关于javascript - AngularJS:为什么我不能使用箭头键从文本框中选择自动完成列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24644601/

相关文章:

javascript - Angular如何向 Node 发送get请求

javascript - 如何通过命令行参数设置 Protractor chromeOptions

jquery - JQVMap区域点击错误

javascript - 使用 jQuery 1.8.3 与 1.9.1 的 CORS

javascript - 使用变量的值作为对象索引

javascript - 选择下拉值时获取 [object, object] - 而不是表

jquery - 分组复选框并允许在每组中最多检查三个

javascript - 如何通过自定义属性获取另一个元素内元素内的文本

css - 在 AngularJS 指令中调整 div 的大小?

javascript - Angular 将输入光标设置为下一个输入,PS : next input tag will be dynamically added on keyEnter of previous input click