apps
apps

Reputation: 333

uib-typeahead not working for angularjs1.x

i am creating uib-typeahead using reference from https://angular-ui.github.io/bootstrap/. But dropdown is not coming. I searched everywhere and doing exactly what others say but dropdown is not coming.

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"];
});

Here is the plunker: https://plnkr.co/edit/qQAGX7u6JJursmItfrf6?p=preview

Please tell me where i am going wrong

Upvotes: 2

Views: 4798

Answers (2)

Daniella
Daniella

Reputation: 129

Use typeahead instead of uib-typeahead. If you really need to use uib-typeahead, check the version of angular-bootstrap-ui. Should be bigger then 0.14.

Check out the changes that you need to need if you do the migration to a newer version: https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.3.3/ui-bootstrap-tpls.js

Upvotes: -1

Enkode
Enkode

Reputation: 4783

First off you have a DI with States that is incorrect:

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

Should be:

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

Second do you plan on using older versions of Angular and UI bootstrap? This one works but it is with the latest version of uib and angular: https://plnkr.co/edit/hQwGKnzLOU0veR6TSnwg?p=preview

Upvotes: 0

Related Questions