AngularJS + UI Bootstrap Typeahead: preload value from object into input field
You can use the product object
as ng-model
. And then you can simply get the id
use form.product.id
.
<div ng-controller="MyTabCtrl"> <pre>Model: {{form.product.id | json}}</pre> <p>The goal is to show "Horay!" while the model is set to 1.</p> <input type="text" autocomplete="off" ng-model="form.product" typeahead="option as option.name for option in p.options | filter:$viewValue" /> <p>Try to write "Audi".</p></div>