我第一次使用Angular JS。
这是我的代码,它不起作用。 typeahead intellisense显示为“未知属性”。
<div class='container-fluid' ng-controller="HomeController">
<h4>Search State</h4>
<pre>Model: {{selected | json}}</pre>
<input type="text" autocomplete="off" ng-model="selected" typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control">
</div>
function HomeController($scope, $http) {
$scope.selected = undefined;
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
}
我错过了一些JS文件吗?
答案 0 :(得分:2)
请在此处查看工作示例http://plnkr.co/edit/SjASFL8BkKdjLRxUlGVA?p=preview
确保你有这些脚本
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
您的应用定义包括ui.bootstrap
var app= angular.module('app', ['ui.bootstrap']);