gpt4 book ai didi

javascript - 如果 ng-repeat multi 过滤器为空,则 Angular

转载 作者:行者123 更新时间:2023-11-30 17:01:54 24 4
gpt4 key购买 nike

假设我的 ng-repeat 中有多个过滤器,如下所示:

input.search(ng-model="filter", placeholder="Search...")

ul.list
li(ng-if="things.length === 0") It looks like we don't have any things.
li(ng-repeat="thing in things | orderBy:'name' | filter: search")
span {{ thing.name }}

现在,如果我最初没有things,那么我会收到这样的消息。但是,如果我过滤了没有结果的东西,它就不会显示消息,我理解这一点。

我的问题是,如何实现多过滤器 ng-repeat 并在收集或过滤器没有结果时显示消息?

我在搞乱 this example无济于事。我的尝试:

thing in filteredThings = thing | orderBy: 'name' | filter: search

最佳答案

你很接近,语法有点不对:

(ng-repeat="thing in filteredThings = (things | orderBy:'name' | filter: search"))

li(ng-if="filteredThings.length === 0") It looks like we don't have any things.

关于javascript - 如果 ng-repeat multi 过滤器为空,则 Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684735/

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