可以说我在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/

10-13 02:26