Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the AngularJS BootstrapUI Typeahead, what's $viewValue?

I'm trying to implement a typeahead in Angular using http://angular-ui.github.io/bootstrap/

Seems like it should be easy, but I'm getting the following error:

Global symbol $viewValue requires explicit package name.

What is $viewValue? It doesn't seem to be defined.

Thanks

like image 444
stampeder Avatar asked Jul 24 '13 14:07

stampeder


People also ask

What is$ uibModal?

$uibmodal is a service to create modal windows. Uibmodal is the UI Bootstrap component written in AngularJS. It enables us to use Bootstrap in AngularJS. It provides directives for all bootstrap with some extra like, datepicker, timepicker etc.

What is Typeahead AngularJS?

Firstly, the typeahead directive uses syntax very similar to the AngularJS select directive. This gives you full control over a displayed label and the data bound as model value.

What is $viewValue?

$viewValue is the current value in the view - your string input.


1 Answers

here is a working typeahead example:

<div class="container">     <div ng-controller="mainCtrl" class="row-fluid">         <form class="row-fluid">             <div class="container-fluid">                 <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue" />             </div>         </form>     </div> </div>  <script> angular.module('myApp', ['ui.bootstrap']) .controller("mainCtrl", function ($scope) {    $scope.selected = '';    $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']; }); </script> 

http://jsfiddle.net/alfrescian/ZjPWe/

$viewValue is the current value in the view - your string input. $viewValue is specified in ngModel.

like image 52
alfrescian Avatar answered Oct 05 '22 21:10

alfrescian