1

I am using AngularJS NG-Repeat directive. I am using a object which looks like this.

{ "filters": [ { "name": "Test", "items": [ { "id": "1207700620", "checked": true }, { "id": "1207825584", "checked": true }, { "id": "1207969166", "checked": true } ] }, { "name": "Empty", "items": [] // This record must be ignored } ] } 

I am using below code to utilize ng-repeat

<li ng-repeat="filter in myData.filters"> {{filter.name}} 

problem: I want to show only those records (name ) where items arrays length is > 0. How can I apply filter for same??

1 Answer 1

1

This is how I am doing it:

on the html page:

<li ng-repeat="filter in myData.filters | filter: filterOnLength"> 

In the controller, added a function by name filterOnLength and in controller:

$scope.filterOnLength = function(item){ return item.items.length > 0; } 
Sign up to request clarification or add additional context in comments.

1 Comment

I have exactly the same situation as yours, and used your filterOnLength to solve it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.