如何显示/隐藏基于“|过滤器”;结果在AngularJS中

How to show/hide a UI component based on "|filter" results in AngularJS?

本文关键字:过滤器 结果 AngularJS 何显示 显示 隐藏      更新时间:2023-09-26

我有一个嵌套的表结构,其中一个表基于Javascript对象"metasetHashSplit"的ng重复进行填充,而这个表又有一个表,该表基于名为"ids"的属性进行填充。我有一个要求,如果内部表中的所有元素都被过滤掉,我需要隐藏主ng重复。我对内部表使用"管道"/"|"过滤器。如果内部表中的所有记录都被过滤掉了,我无法确定何时或如何触发ng显示/隐藏。

这就是代码的设置方式:

<tbody  ng-repeat="(metaset, ids) in metasetHashSplit">
<tr class = "meta">
    <td   rowspan = 100 >{{metaset}}</td>
</tr>
<tr class = "meta" style="margin:0;padding:0;"  ng-repeat="item in ids" >
    <td class = "innerTable">
        <table class="table  child table-hover table-bordered table-condensed " >
            <tr ng-repeat="buy in item.Buy  | filter:{ MBC: by_buyMBC }" >
                <td >{{buy.BuyId}}</td>
                <td >{{buy.BuyRelease}}</span></td>
                <td >{{buy.BuyComponentAffected}}</td>
                <td >{{buy.BuyStatus}}</span></td>
            </tr>
        </table>
    </td>
</tr>

如果他们发现自己处于这样的境地,有人能帮我吗?基本上,tbody需要显示/隐藏关于|filter:{MBC:by_buyMBC}结果!

基于此问题使用:

<div ng-repeat="buy in filtered = (item.Buy | filter:{ MBC: by_buyMBC })">
</div>

因此,您所要做的就是在右侧元素

上使用ng-if="filtered.length > 0"来显示和隐藏