角+离子,NG选项执行选择期权价值标签 [英] Angular + Ionic, ng-options implement value tag in select options
本文介绍了角+离子,NG选项执行选择期权价值标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 NG-选项
在<选择>
这样的纳克-options =item.model在prodataSelect项目|独特:模式
不过,我想在<值=
的生成选项包含标记 item.id
而不是由NG选项的自动增加值使用。
如何实现这一点?
HTML
<选择一个id =chosenmodel级=按钮按钮按钮全暗NG模型=selectedModelNG选项=item.model在prodataSelect项目|独特:'模型'>
<期权价值=>选择型号< /选项>
< /选择><一个ID =提交按钮级=按钮按钮块纽扣暗UI的BTN UI的BTN-B UI的角落,所有的NG点击='launchCompute()'HREF =#/应用/计算/结果>计算我的板< / A>
在 prodataSelect
的每个项目都是一个对象:
{
品牌:约翰,
有趣:0,
ID:1
},
{
品牌:你,
有趣:0,
编号:185
},
{
品牌:方舟,
有趣:0,
编号:17
},
解决方案
下面的语法使用
`NG选项=item.id作为item.model在prodataSelect项`
I am using ng-options
on a <select>
like this ng-options="item.model for item in prodataSelect | unique:'model' "
But I would like the <value=""
tag of the generated options to contain the item.id
instead of the autoincremental value use by ng-options.
How to achieve this ?
HTML:
<select id = "chosenmodel" class="button button-full button-dark" ng-model="selectedModel" ng-options="item.model for item in prodataSelect | unique:'model' ">
<option value="">Select a Model</option>
</select>
<a id="submitbutton" class="button button-block button-dark ui-btn ui-btn-b ui-corner-all" ng-click='launchCompute()' href="#/app/compute/result">Compute my board</a>
Each item in prodataSelect
is an object :
{
brand: "John",
fun: "0",
id: 1
},
{
brand: "you",
fun: "0",
id: 185
},
{
brand: "Ark",
fun: "0",
id: 17
},
解决方案
use below syntax
`ng-options="item.id as item.model for item in prodataSelect"`
read more about it here
这篇关于角+离子,NG选项执行选择期权价值标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文