你能告诉我,如何选择这样的选择:
<select ng-model="model.user" ng-options="user._id as user.title for user in users">
<option value="43f01">John Doe - Administrator</option>
<option value="43f02">Adam Smith - Superviser</option>
</select>
来自这些数据:
[
{ "name" : "John Doe", "title" : "Administrator", "_id":"43f01"},
{ "name" : "Adam Smith", "title" : "Superviser", "_id":"43f02"},
]
任何建议都非常感谢。
答案 0 :(得分:2)
ng-options
接受选项文本的角度表达式,你可以在那里创建字符串
<select ng-model="model.user" ng-options="user._id as (user.name + ' - ' + user.title) for user in users">