<!doctype html>
<html ng-app="ui.bootstrap.demo">
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
  <div class='container-fluid' ng-controller="TypeaheadCtrl">
    <form name="myform"> 
        <h4>Static arrays</h4>
        <input type="text" ng-model="model.street" class="form-control" placeholder="street">
        <input 
          type="text" 
          ng-model="model.state" 
          typeahead="state.code as state.code for state in states | filter:$viewValue | limitTo:8" 
          ng-required="true"
          class="form-control" 
          placeholder="state"
          typeahead-editable="false"
          >
        <button ng-click="reset()">RESET</button>
    </form>
    <pre>Model: {{model | json}}</pre>
  </div>
  </body>
</html>
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl', function($scope, $log, $http) {
  $scope.model = {};
  $scope.states = [{'name':'Alabama', 'code' : 'AL'}, {'name' : 'Alaska', 'code' : 'AK'}];
  // Any function returning a promise object can be used to load values asynchronously
  $scope.reset = function(){
    debugger;
    $scope.model = {};
    $log.log($scope);
    //$scope.myForm.$setPristine();
  }
});