javascript - AngularJs ng-通过更深层次的数据重复过滤

标签 javascript angularjs

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

在 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-通过更深层次的数据重复过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37255220/

相关文章:

angularjs - 像AngularJS中的模板引用一样吗?

javascript - 将 Firebase 注入(inject) AngularFire 时找不到 $firebaseObject

javascript - 强制重新加载指令模板

javascript - 使用 controllerAs 语法时将当前范围传递给 modalInstance

javascript -/regex/(string) 被认为是有害的?

javascript - 有没有一种方法可以检查 javascript 以毫秒为单位执行一个函数需要多长时间?

javascript - 按下 React-native 按钮会执行 3 次 Firebase 数据库更新中的 2 次

javascript - 将 .NET Core 环境传递给 React.JS 应用程序

javascript - Chrome扩展本地存储从多个地方访问

angularjs - 是否可以在不依赖 jQuery UI 的情况下使用 AngularJS 实现拖放功能?