我正在尝试使用基于ng-option的下拉菜单。我的代码目前看起来像这样:
<select
ng-options="choice.id as choice.singular in model.quanityChoices"
ng-model="med.id"
<option value=""></option>
</select>
基于此的模型数据如下所示:
[
{id: 1, singular: 'word'},
{id: 2, singular: 'word2'}
]
目前我的目标是有一个下拉列表,用户将看到选项'word'和'words',但应用的值是ID。
目前我的代码有以下错误:
Error: [ngOptions:iexp] Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got 'choice.id as choice.singular in model.quantityFormChoices'. Element: <select...
答案 0 :(得分:3)
您没有正确构建它,查看错误,因为它为您提供了有关如何执行此操作的详细信息:
<select
ng-options="choice.id as choice.singular for choice in model.quanityChoices"
ng-model="med.id"
<option value=""></option>
</select>