0

i use angular bootstrap typeahead (this lib ui-bootstrap-tpls.js ) in my app, when use two typeahead in one scope, only one work well, and other not work, this is my code

angular.module('plunker', ['ui.bootstrap']);
function TypeaheadCtrl($scope) {

    $scope.selected = undefined;
    $scope.selected2 = undefined;

    $scope.states = ['Alabama', 'Alaska','California', 'Hawaii',  'Wisconsin', 'Wyoming'];
}

<html ng-app="plunker">
    <head>
    <title></title>
    <link href="lib/angular-bootstrap/bootstrap.css" rel="stylesheet" />
    <script src="lib/angular/angular.js"></script>
    <script src="lib/angular-bootstrap/ui-bootstrap-tpls-0.3.0.min.js"></script>
    <script src="app.js"></script>
    </head>
    <body>
        <div class='container-fluid' ng-controller="TypeaheadCtrl">
        <pre>Model: {{selected| json}}</pre>
        <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue">
        <input type="text" ng-model="selected2" typeahead="state for state in states | filter:$viewValue">
        </div>
   </body>

please check this and help.

2

1 Answer 1

1

It was cross-posted as the issue on GitHub as well: https://github.com/angular-ui/bootstrap/issues/562

It is not a bug in the typeahead code, it simply requires AngularJS version >= 1.0.4

Here is a working plunk with cleaned-up dependencies: http://plnkr.co/edit/00xjmfCR5A3Gb7VMC3Ta?p=preview

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using Angular 1.2.7 and having the same issue. Do you know anything of it?
1.2.7 seems to be working perfectly fine: plnkr.co/edit/aLdcutPxBfvnVW5foioo?p=preview
It seems I've got a funny one: On my first typeahead instance works well. A copied the instance and changed the model name and object property that should be used to search (I've got a customer object which has several properties in it and I want the user to be able to search a customer by several properties) and it works with matchItem error. I duplicate again (changing model and property again) and the third one works flawlessly. I'm probably missing something obvious...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.