我有Json请求如下。我需要在表格中仅使用intrsted
中的键来过滤值。我是过滤器和角度处理键的新手。我附上了我的JSON请求和响应,需要帮助。
JSON:
var customer =
[
[
{
"businessuserid": 44,
"businessusername": "rk business New",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": false,
"emailvalidated": false,
"email": "riteshnew@gmail.com",
"upin": "000044"
}
],
[
{
"approved": true,
"businessuserid": 43,
"businessusername": "Cakey Bakes",
"businessusermobile": "8050663763",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "preethi@groupz.com",
"upin": "000043"
}
],
[
{
"intrsted": true,
"attended": false,
"businessuserid": 44,
"businessusername": "rk business New",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": false,
"emailvalidated": false,
"email": "riteshnew@gmail.com",
"upin": "000044"
}
],
[
{
"intrsted": true,
"attended": false,
"businessuserid": 52,
"businessusername": "Cars workshop",
"businessusermobile": "9535000636",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "preethi@car.com",
"upin": "000052"
}
]
HTML:
<table ng-repeat="item in customers | filter: { intrsted: true }">
<td>{{item.businessusername}}</td>
<tr>
</table>
答案 0 :(得分:1)
您的过滤器使用没有任何问题。您的 ng-repeat 用法存在问题。如果仔细检查json对象,您将看到每个项目都是另一个数组,因此您需要将内部对象用作数组。像你这样修复你的HTML
<table ng-repeat="item in customers | filter: { intrsted: true }">
<td>{{item[0].businessusername}}</td>
</table>
您看到项目只是另一个数组,因此请使用项目[0],您将得到您想要的结果......
<强>更新强>
用于在html上显示内部数组列表,在第一次ng-repeat中使用第二次ng-repeat ...
<table ng-repeat="item in customers | filter: { intrsted: true }">
<td ng-repeat="customer in item">{{customer.businessusername}}</td>
</table>