角度Ng选项错误?(angular Ng

编程入门 行业动态 更新时间:2024-10-09 17:26:53
角度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...

I am trying to use an ng-option based drop down. My code currently looks like this:

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

The model data this is based off looks like this:

[ {id: 1, singular: 'word'}, {id: 2, singular: 'word2'} ]

Currently my goal is to have a dropdown where the user will see the options 'word' and 'words' but the value that gets applied is the ID.

Currently my code has the following error:

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>

You didn't structure it correctly, look at the error as it gives you the details on how to do it:

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

更多推荐

id,singular,'word',目前,<select,电脑培训,计算机培训,IT培训"/> <me

本文发布于:2023-07-17 14:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   角度   错误   angular   Ng

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!