I have a typeahead that I want to contain a description but store the Id.
I'm currently doing it something like this...
<input type="text"
ng-model="SelectedWarehouse.Info"
typeahead="whs.info for whs in warehouses($viewValue)"
typeahead-on-select="POHeader.warehouseId=$item.id;"
class="form-control input-sm "
id="whs" placeholder="Warehouse"
ng-disabled="isReadOnly"
typeahead-wait-ms="500"
ng-enter="say('hello');" />
Where the jsonp that I get from the $scope.warehouses function looks something like this: ([{"id":"10", "info": "Lakeland (10)"}, {"id":"11", "info": "Denver (11)"}]) of course along with the appropriate jsonp callback info -- this is just an example
The sloppy part of it is this: When the screen opens the $scope.SelectedWarehouse is not populated with anything. I then wrote something to pre-populate the SelectedWarehouse but there has to be a better way to do this using typeahead.
What's the right/good/best (pick one) way to do this?
Another problem is not knowing when my async call will actually populate my objects. Promises promises... I thought I'd try using the ng-change function call hoping that when the data gets populated the ng-change function would fire ... so far that didn't work. I'm not quite done experimenting with that though...
Here's part of my $resource factory. What would I need to do to get a success call working with this?
ipoModule.factory('SearchRepository', function ($resource) {
return {
get: function (txt) {
return $resource('/api/Search?SearchText=' + txt).query()
},
getBuyers: function () {
return $resource('api/Buyers').query()
},
getVendors: function () {
return $resource('api/Vendors').query()
},
getVendorSearch: function (txt) {
return $resource('api/Vendors/' + txt + "?callback=JSON_CALLBACK").query()
}, ....
Any ideas?