我在特定值的ng-repeat过滤中有一个ng-repeat,如果没有内部过滤器生成的值,我想隐藏外部过滤器div,这可能吗?
<div class="feedEntry" ng-repeat="entry in entries | orderBy:'-' track by $index" ng-if="entry.userID" ng-if="entry.hasFollowing">
{{entry.hasFollowing}}
<span ng-repeat="follow in follows | filter:{following:entry.userID, follower:currentUser.userID}">
<div class="feedUserSubmission" ng-init="entry.hasFollowing = true">
{{entry.name}}
</div>
</span>
</div>
答案 0 :(得分:2)
好吧,如果我找不到解决方案,我会采取一种解决方法。
你只需在内部ng-repeat中执行$parent.showParent = true
,只有在内部ng-repeat过滤结果时才会执行,从而影响外部ng-repeat的范围。
然后你会在外部ng-repeat
上做ng-show="showParent"
之类的事情
<div class="feedEntry" ng-repeat="entry in entries | orderBy:'-' track by $index" ng-show="showParent" ng-if="entry.userID" ng-if="entry.hasFollowing">
{{entry.hasFollowing}}
<span ng-repeat="follow in follows | filter:{following:entry.userID, follower:currentUser.userID}" ng-init="$parent.showParent = true">
<div class="feedUserSubmission" ng-init="entry.hasFollowing = true">
{{entry.name}}
</div>
</span>
</div>
答案 1 :(得分:1)
如果你想隐藏所有含义父div的内容:
<div ng-show="(follows | filter:filterByGroup(entry)).length">
<div class="feedEntry" ng-repeat="entry in entries | orderBy:'-' track by $index" ng-if="entry.userID" ng-if="entry.hasFollowing">
...
</div>
</div>
答案 2 :(得分:1)
您可以使用具有内部过滤条件的ng-hide
ng-hide =&#34;(follow | filter:{following:entry.userID,follower:currentUser.userID})。length == 0&#34;
e.g。
<div class="feedEntry" ng-repeat="entry in entries | orderBy:'-' track by $index" ng-if="entry.userID" ng-if="entry.hasFollowing" ng-hide="(follows | filter:{following:entry.userID, follower:currentUser.userID}).length == 0">
{{entry.hasFollowing}}
<span ng-repeat="follow in follows | filter:{following:entry.userID, follower:currentUser.userID}">
<div class="feedUserSubmission" ng-init="entry.hasFollowing = true">
{{entry.name}}
</div>
</span>
</div>