Angular UI Typeahead Sample

Toying around with Angular UI Typeahead

by sunil puvvada

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.0/ui-bootstrap-tpls.min.js"></script>
<body ng-app="TypeaheadDemo">
    <div class="container-fluid" ng-controller="TypeaheadCtrl">
        <h1>Angular UI Bootstrap Typeahead</h1>
        <input type="number" ng-model="query" class="form-control" 
               typeahead="result for result in results | filter: $viewValue" />
    </div>
</body>

JavaScript

angular.module("TypeaheadDemo", ['ui.bootstrap'])
.controller('TypeaheadCtrl', ['$scope', function($scope) {
    $scope.query = "";
    $scope.results = ["500031, hyderabad, INDIA", 
                      "iPhone 6, hyderabad, INDIA", 
                      "Calculus Textbook, hyderabad, INDIA",
                      "Galaxy Note 3 S-Pen, Chennai, INDIA",
                      "2.5ft Mini Fridge, Guntur, INDIA",
                      "Speakers, Vijayawada, INDIA",
                      "Razer Ultimate Mechanical Keyboard, Machilipatnam, INDIA"];
}]);