gpt4 book ai didi

javascript - 如何在自定义过滤器中添加多个参数?

转载 作者:行者123 更新时间:2023-12-02 15:11:53 28 4
gpt4 key购买 nike

以下过滤器使 ng-repeat 仅显示带有 isOutRoom truepano:

<tr ng-if="building.pano.length" ng-repeat="pano in panos | filter: filterByRoom">

$scope.filterByRoom = function(pano, room) {
return pano.isOutRoom === true
}

我还想要另一个 ng-repeat,它只显示 pano,并将 isVirtualRoom 设置为 true

如何向过滤器添加第二个参数,以便我可以在 isOutRoomisVirtualRoom 之间进行选择?

我尝试过这个:

<tr ng-if="building.pano.length" ng-repeat="pano in panos | filter: filterByRoom: pano.isOutRoom)"

$scope.filterByRoom = function(pano, room) {
return pano.room === true

但是现在 ng-repeat 中没有显示任何内容。

最佳答案

您可以使用分隔参数:

过滤器:filterByRoom:第二个参数:第三个参数

编辑:看起来这篇文章更详细地回答了问题:https://stackoverflow.com/a/16227326/841804

关于javascript - 如何在自定义过滤器中添加多个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34763505/

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