【发布时间】:2017-12-04 14:06:18
【问题描述】:
我正在调用一个 API,它将返回一个 json 对象。基于某些条件,我从这个 Json 对象中获取值并将它们显示在可以使用 Angular JS 重复的表中。现在我需要获取每个表的数据,但我不知道如何过滤某些数据。下表是:
<table class="table">
<thead>
<tr>
<th>Relation
</th>
<th>Date Of Birth
</th>
<th >In Hospital
</th>
<th >AMB & PM
</th>
<th > Total
</th>
</tr>
</thead>
<tr ng-repeat="member in CalculatorResponse">
<td>
{{member.Relation}}
</td>
<td>{{member.dateOfBirth}}
</td>
<td>
<span ng-repeat=" InHosp in member.InHospital | filter:{strClassName: class.className}">
{{InHosp.intClassValue}}
</span>
</td>
<td >
<span ng-repeat=" OutHosp in member.OutHospital | filter:{OptionType: Option_Select.type}">
<span ng-model="AMBPMVal" ng-repeat=" Benefits in OutHosp.Benefits | filter:{intExcess: CoBenefitsSelect.type}">
{{Benefits.intAMBPM}}
</span>
</span>
</td>
<td> Total value (unable to calculate it) {{InHosp.intClassValue}} + {{Benefits.intAMBPM}}
</td>
</tr>
</table>
<input type="button" value="Generate" ng-click="Generate()"/>
所以主要问题是我在点击生成按钮时试图获取表的所有值,但我无法获取过滤后的值;
-
我这样做了,但它不起作用:
<span ng-repeat=" OutHosp in (filteredHosp = (member.OutHospital | filter:{OptionType: Option_Select.type}))"> <span ng-repeat=" Benefits in (filteredBenefits = (OutHosp.Benefits | filter:{intExcess: CoBenefitsSelect.type}))"> {{Benefits.intAMBPM}} </span> <%--{{filteredBenefits[0].intAMBPM}}--%> </span> <%--{{filteredHosp[0].Benefits}}--%>
-->过滤的好处和过滤的Hosp只能在评论区域访问,如果您将它们放在2个跨度之外,您将一无所获。
- 我也在尝试计算 In Hospital 和 AMB&M 的总数,但我不能,因为我不知道如何在过滤后获得它们的值。
有什么建议吗?
【问题讨论】:
标签: angularjs json angularjs-ng-repeat angularjs-filter