AngularJS - hide parent element if children loop is empty (filtered)

前端 未结 3 1921
别跟我提以往
别跟我提以往 2021-01-01 19:16

I have a case in which I have nested loops in which the child one is constructed by a filter function that takes parent as the argument. I also have another filter that just

3条回答
  •  轮回少年
    2021-01-01 19:40

    If you can ask for the materials by group and you expect to do that for each group anyway, why not do that right away when you initialize the view and build a model with groups that have materials? If you can do that you can use ng-show to only hide groups that have materials.

    You seem to need to know that a group has materials or not somehow? Here's a fiddle without knowing much of the background story:

    {{group.name}}
    {{material.name}}

    fiddle with groups

提交回复
热议问题