繁体   English   中英

角度Ng选项错误?

[英]angular Ng-options error?

我正在尝试使用基于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...

您没有正确构造它,查看错误,因为它为您提供了有关如何执行此操作的详细信息:

<select
     ng-options="choice.id as choice.singular for choice in model.quanityChoices"
     ng-model="med.id"
     <option value=""></option>
</select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM