angularjs - 如何在不知道数据模型的情况下显示对象数组
问题描述
我有一个对象数组,这是我的对象结构:
[{
"_index": "bank",
"_type": "account",
"_id": "25",
"_score": 1,
"_source": {
"account_number": 25,
"balance": 40540,
"firstname": "Virginia",
"lastname": "Ayala",
"age": 39
}
}, ... ]
我需要消除_index、_type、_id、_score(仅显示_source),并且我想在每个键之前显示一个包含值的输入:
帐号:[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>
NW:我知道,我正在编写愚蠢的代码,仅出于一个原因,来解释我的需求。
解决方案
做ng-repeat="(key,value) in row._source"
:
<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>
推荐阅读
- android - java.lang.IllegalStateException:期望 .、< 或 ;,但在解包时发现 firebaseperf
- javascript - 防止jquery datepicker在日期点击时重定向
- angular - 在 Angular 5 中,如何在路由到不同视图之前执行动画?
- angular - 如何在 angular2 应用程序的 Prime ng 中提供内联编辑和删除按钮以及新按钮
- c - 插入数组期间整数值发生变化
- ruby - 如何安全加载包含多个文档的 YAML 文件?
- spring-boot - 为 AWS cloudwatch 的 Micrometer 配置 SpringBoot 2 应用程序
- database - 如何覆盖odoo 11中的数据库选择器网页?
- forms - 提交前和数据输入时的表单验证
- c# - 模型状态错误过滤器