Angularjs 如何在不知道数据模型的情况下显示对象数组
我有一个对象数组,这是我的对象结构:Angularjs 如何在不知道数据模型的情况下显示对象数组,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,我有一个对象数组,这是我的对象结构: [{ "_index": "bank", "_type": "account", "_id": "25", "_score": 1, "_source": { "account_number": 25, "balance": 40540, "firstname": "Virginia", "lastname": "Ayala", "age": 39 } }, ... ] 我需要消除\u索引,\
[{
"_index": "bank",
"_type": "account",
"_id": "25",
"_score": 1,
"_source": {
"account_number": 25,
"balance": 40540,
"firstname": "Virginia",
"lastname": "Ayala",
"age": 39
}
}, ... ]
我需要消除\u索引,\u类型,\u id,\u分数(仅显示\u源),我想在每个键前显示一个包含以下值的输入:
账号:[25]
余额:[40540]
<tbody>
<tr ng-repeat="row in ctrl_hits.data | limitTo: row._index+row._type+row._id+row._score">
<td> {{row.key}} :
<input type="text"
ng-value="row.value">
</td>
</tr>
</tbody>
{{row.key}}:
NW:我知道,我在写愚蠢的代码,只是出于一个原因,来解释我的需求。首先,你必须使用数组映射函数来消除无用的数据(\u索引、\u类型等),并保留\u源 如果x是对象数组,则ctrl_hits.data将有一个数组,其中包含以前数据的_源对象
ctrl_hits.data=x.map(function(e){
return e._source;
})
然后在你的html
<tbody>
<tr ng-repeat="item in ctrl_hits.data">
<td ng-repeat=(key,value) in item>
{{key}} : <input type="text" ng-model="value"/>
</td>
</tr>
</tbody>
{{key}}:
Dong repeat=“(键,值)在行中。_source”
:
{{key}}:
<tbody>
<tr ng-repeat="row in ctrl_hits.data | limitTo: row._index+row._type+row._id+row._score">
<td ng-repeat="(key,value) in row._source">
{{key}} :
<input type="text" ng-model="row._source[key]">
</td>
</tr>
</tbody>