gpt4 book ai didi

javascript - 如果所有数组项都被隐藏,则在 AngularJS 中显示另一个 div

转载 作者:行者123 更新时间:2023-11-30 15:02:55 26 4
gpt4 key购买 nike

我在我的页面上使用 ng-repeat。 ng-class 运行良好。

  <div class="card news" ng-repeat="item in news track by $index" id="{{news.nid}}" ng-init="parentIndex = $index" ng-class="{hidden: '{{getCheck($index)}}' == 'true'}">
...

</div>

现在我需要,如果所有项目都被隐藏,显示这个 div:

<h3 class="news-empty">No news</h3>

规则是什么?我该怎么做?谢谢。

最佳答案

您需要另一种方法来检查是否所有元素都被隐藏:

$scope.everythingIsHidden = function() {
return $scope.news.every((new, index) => $scope.getCheck(index));
}

$scope.getCheck = function(index) { // Your getChek function that I suppose it checks if an element is hidden based on index
//...
}

<h3 class="news-empty" ng-if="everythingIsHidden()">No news</h3>

关于javascript - 如果所有数组项都被隐藏,则在 AngularJS 中显示另一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46238587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com