我正在调用一个将返回json对象的API。基于某些条件,我从这个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}}--%>
- &GT;过滤的好处和filteredHosp只能在注释区域中访问,如果你把它们放在2个跨度之外就不会得到任何东西。
有什么建议吗?
答案 0 :(得分:2)
它们不可用,不是因为过滤器,而是因为它们超出了ng-repeat的范围。您可以在ng-repeat中进行计算,也可以遍历列表并在控制器中进行计算。