我在另一個對象內部有一個數組對象。所以,在我的html中有兩個嵌套的ng-repeat。我試圖隱藏標籤數據如果行動不是「更改」 爲前。在下面的例子中,最後一行「更改的L3」不應該顯示。如何根據內部數組值對外部數組記錄進行過濾
我的範圍數據:
$scope.groups =
[{
"label": "L1",
"tabledata": [{
"FIELDNAME": "C1 Entity",
"SCREEN": "A",
"ORIGINALVALUE": "NA",
"ACTION": "Changed",
"NEWVALUE": "Something",
"TYPEACT": "RB"
},
{
"FIELDNAME": "C2 Entity",
"SCREEN": "A",
"ORIGINALVALUE": "NA",
"ACTION": "Changed",
"NEWVALUE": "SSSS",
"TYPEACT": "RB"
}
]
},
{
"label": "L2",
"tabledata": [{
"FIELDNAME": "B1 Entity",
"SCREEN": "B",
"ORIGINALVALUE": "NA",
"ACTION": "Changed",
"NEWVALUE": "Something",
"TYPEACT": "RB"
},
{
"FIELDNAME": "B2 Entity",
"SCREEN": "B",
"ORIGINALVALUE": "NA",
"ACTION": "Changed",
"NEWVALUE": "Something",
"TYPEACT": "RB"
}
]
},
{
"label": "L3",
"tabledata": [{
"FIELDNAME": "A Entity",
"SCREEN": "C",
"ORIGINALVALUE": "NA",
"ACTION": "Added",
"NEWVALUE": "Something",
"TYPEACT": "RB"
}]
}]
我的HTML在ACTION屬性
<div ng-repeat="group in groups" >
<p><b>{{ "Changed " + group.label }}</b>
</p>
<table class="table table-bordered" >
<tbody >
<tr >
<th width ="20%"><b ng-bind="column1" ></b></th>
<th width ="40%"><b>Previous value </b></th>
<th width ="40%"><b ng-bind="column3" ></b> </th>
<th width ="10%"><b>Action </b></th>
</tr>
<!-- BEGIN: Inner ngRepeat. -->
<tr ng-repeat="endorsedata in group.tabledata | filter :{ACTION : 'Changed'} | orderBy:'FIELDNAME' " >
<td ng-init ="showRow = 1">{{ endorsedata.FIELDNAME }}</td>
<td>{{ endorsedata.ORIGINALVALUE }}</td>
<td>{{ endorsedata.NEWVALUE }}</td>
<!-- <td>{{ endorsedata.ACTION }}</td> -->
</tr>
<!-- END: Inner ngRepeat. -->
</tbody>
</table>
</div>
我想隱藏標籤,如果有比其他值 '改變'。這如何實現?
編輯: Plunker鏈接更新。
是的,這並不困難,如果你創建一個過濾器,那麼它的內部使用'$ filter'就可以實現這個功能。非常坦率的。看看'$ filter'源代碼 –