[英]Accessing an object from ng-option
关于蜜蜂访问对象的问题很多,但我找不到能回答我问题的对象。
我有一个动态创建的对象,像这样:
{
id: "ISO 19115:MD_Metadata:identificationInfo:extent:temporalElement:extent",
value: "ISO 19115:MD_Metadata:identificationInfo:extent:temporalElement:extent:endPosition",
begin: "ISO 19115:MD_Metadata:identificationInfo:extent:temporalElement:extent",
...
}
我想在ng-options(angularJS)中显示第二个参数的对(id-ISO 19115:MD ...,值-ISO 19115:MD ...),这是通过第一个参数的路径。
所以我想知道这样的事情是否可行:
<select ng-model='selectedtype' ng-options="(item[0] + item[1]) for item in types">
<option value="">select type</option>
</select>
请注意,我的对象在$scope.types
。
这是行不通的,因此是否有解决方案,例如用于访问name:value对的指定关键字。
我知道这对于设计一个对象是很糟糕的,我应该尝试这样的事情:
{
[
{
'name': 'id',
'value':'ISO 19115 ...',
},
....
]
}
但是,如果可能的话,我将不胜感激。
ng-options
支持字符串连接。 因此您可以轻松使用类似
ng-options="'id-'+item.id+', value-'+item.value for item in types"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.