How do I only show an element if nested ng-repeat is not empty?

前端 未结 6 1938
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 11:01

I have a List of lists, created with a nested ng-repeat. Each outer ng-repeat contains a div with the label of its inner list (eg: \"Group A\"). I\'m now trying to create a

6条回答
  •  一个人的身影
    2020-12-25 11:23

    you could leverage ng-init, that way you'll call the filter only once:

    {{key}}
    • {{el.label}}

    usually it is not a good practice to use ng-init out of no where, but I guess it solves calling the filter twice. Another way is to use the filter through javascript - you could inject $filter and retrieve 'filter' $filter('filter') in your controller, calling it with group as its first argument, the filterFn as its second, and store its result in your scope.

提交回复
热议问题