2016-03-26 33 views
2

我使用https://angular-ui.github.io/bootstrap/中的参考来创建uib-typeahead。但下拉不来。我到处搜索,并且正在做别人说的话,但下拉不会到来。uib-typeahead不能正常工作

HTML:

<div> 
    <pre>Model: {{tc.selected | json}}</pre> 
    <input type="text" ng-model="selected" uib-typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control"> 
</div> 

JS:

var myApp = angular.module("angularTypeahead", ["ui.bootstrap"]); 

myApp.controller("TypeaheadCtrl", function($scope, States) { 
    $scope.states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois"]; 

}); 

这里是plunker: https://plnkr.co/edit/qQAGX7u6JJursmItfrf6?p=preview

请告诉我,我错了

回答

0

首先你有DI与国家是不正确的:

myApp.controller("TypeaheadCtrl", function($scope, States) 

应该是:

myApp.controller("TypeaheadCtrl", function($scope) 

其次你打算使用老版本的角度和用户界面引导的?这一个工程,但它与最新版本的uib和角:https://plnkr.co/edit/hQwGKnzLOU0veR6TSnwg?p=preview