title: AngularJS BootstrapUI Typeahead with object & selection functionality
body: <p>I'm trying to implement a typeahead in Angular using <a href="http://angular-ui.github.io/bootstrap/">http://angular-ui.github.io/bootstrap/</a>, where the typeahead field displays full addresses but once clicked another field is populated with just the postcode for that address. I'm trying to use ng-change or ng-click for this, but without any success..</p>
  
  <p><a href="http://jsfiddle.net/UxTBB/2/">http://jsfiddle.net/UxTBB/2/</a></p>
  
  <pre><code>angular.module('myApp', ['ui.bootstrap'])
      .controller("mainCtrl", function ($scope) {
      $scope.selected = '';
      $scope.states = [{postcode:'B1',address:'Bull ring'},{postcode:'M1',address:'Manchester'}];
      $scope.setPcode = function(site) {
          $scope.selPcode = site.postcode;
          };
  });
  
  &lt;div class="container"&gt;
      &lt;div ng-controller="mainCtrl" class="row-fluid"&gt;
          &lt;form class="row-fluid"&gt;
              &lt;div class="container-fluid"&gt;
                  postcode &lt;input type="text" ng-model="selPcode" /&gt;
                  typeahead &lt;input type="text"  ng-change="setPcode(site)" ng-model="selected" typeahead="state.address for state in states | filter:$viewValue" /&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Any ideas?</p>