gpt4 book ai didi

javascript - AngularJs ng-repeat 通过更深层次的数据进行过滤

转载 作者:行者123 更新时间:2023-11-29 19:13:12 25 4
gpt4 key购买 nike

在我的约会数据中,我有几个月、几周、几天、时间段

在 ListView 中显示“周”并不重要(但对于其他报告很重要)

对于“天数”,我可以过滤掉没有约会的天数:

<div ng-repeat="month in appointments.months: | filter:{????:''}">
<div>{{month.name}}</div>
<div ng-repeat="week in month.weeks"> <!--Not displaying anything for weeks-->
<div ng-repeat="day in weeks.days | filter:{timeslots:''}">
....</div></div></div>

filter:{timeslots:''} 具有抑制没有约会的天数的预期效果。

我还想取消显示没有约会的月份。我尝试了 |filter:{weeks.days.timeslots:''} 的变体,但没有成功。

是否有直接的(内置的)方法来对 angularjs 中的值进行深度过滤,或者我是否必须为此构建自定义过滤器?

最佳答案

是的,有一种方法存在!!!

A special property name $ can be used (as in {$:"text"}) to accept a match against any property of the object or its nested object properties.
The predicate can be negated by prefixing the string with !. For example {name: "!M"} predicate will return an array of items which have property name not containing "M".

这是 filter解释。

关于javascript - AngularJs ng-repeat 通过更深层次的数据进行过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37255220/

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