javascript - AngularStrap typeahead ng-options - different label than model -
i using angularstrap typeahead addresses. assign selected address object ng-model when lose alternative show 1 of object properties label.
sample returned object:
{ formatted: '1001 main st', geo: { lat: '123', lng: '234' } }
in view:
<input type="text" class="form-control" ng-model="item.venue" ng-options="address address.formatted address in getlocation($viewvalue)" placeholder="enter address" bs-typeahead> venue object: {{ item.venue }}
i have thought above work doesn't assign "formatted" label value - blank after selection. doing next works assigns formatted property model:
<input type="text" class="form-control" ng-model="item.venue" ng-options="address. address.formatted address.formatted address in getlocation($viewvalue)" placeholder="enter address" bs-typeahead>
fiddle: http://jsfiddle.net/cyberwombat/30e63qea/1/
i think mean want input label
or obj.label
of selected obj, want maintain selected info of obj.
you can capture $on selected event add together .label
$scope.$on('$typeahead.select', function(v,i){ console.log(v,i); $scope.selected.label = $scope.selected.formatted_address; });
here's plunker
javascript angularjs
No comments:
Post a Comment