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

前端 未结 3 1891
别跟我提以往
别跟我提以往 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

    A much cleaner solution was suggested HERE.

    What you need to do is wrap the relevant area with an ng-show / ng-if based on an expression that applies the filter on the data structure and extracts length. Here is how it works in your example:

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

    This allows you to hide complex structures once they are empty due to filtering, e.g. a table of results.

提交回复
热议问题