【发布时间】:2016-05-10 07:40:49
【问题描述】:
我在我的 angularjs 项目中使用 typeahead。
我有这个值要显示在带有 typeahead 属性的文本框中:
$scope.cities = [{id:1,address:'Berlin'},
{id:2,address:'Bonn'},
{id:3,address:'London'},
{id:4,address:'Miami'}];
这里是带有预输入属性的输入文本框:
<input type="text" ng-model="selected" typeahead="state.abbreviation as state.name for state in states | filter:$viewValue | limitTo:8">
但是当item被选中时显示的值的id而不是地址的问题。
这里是planker。
我希望地址显示在文本框中,id值保存在selected变量中。如何解决问题?
【问题讨论】:
标签: angularjs twitter-bootstrap angular-ui-bootstrap angular-ui angular-ui-typeahead