victorpavlov
10/29/2015 - 12:38 PM

Filtering Angular repeat array http://toddmotto.com/everything-about-custom-filters-in-angular-js/

app.filter('filterName', function () {
  return function (items, argument) {
    var filtered = [];
    for (var i = 0; i < items.length; i++) {
      var item = items[i];
      // Condition to filter an array.
      // Can have any code.
      if (item.argument) {
        filtered.push(item);
      }
    }
    return filtered;
  };
});

// Sample of implementation:
//<li ng-repeat="friend in person.friends | filterName:argument">
  //  {{ friend }}
//</li>