Skip to main content
added 21 characters in body
Source Link
Azox
  • 1.9k
  • 2
  • 15
  • 22

You can make your own filter in angular, you can try something like this:

  <div ng-controller="ListCtrl">
      <ul ng-repeat="category in categories | customFilter:category">
          <li>{{category.title}}</li>
      </ul>
  </div>

and the filter:

app.filter('customFilter', [function () {
    return function (items) {
        var filtered = [];
    
        angular.forEach(items, function (item) {
      
          if(item.parent === 0 && indexOf(item) < 0) {
            filtered.push(item);
          }
        })

        return filtered;
    }
}]);

See the updated plunker: http://plnkr.co/edit/96aX0cqLT9SJX2YZquns?p=preview

For more information about filters checkout the docs

You can make your own filter in angular, you can try something like this:

  <div ng-controller="ListCtrl">
      <ul ng-repeat="category in categories | customFilter:category">
          <li>{{category.title}}</li>
      </ul>
  </div>

and the filter:

app.filter('customFilter', [function () {
    return function (items) {
        var filtered = [];
    
        angular.forEach(items, function (item) {
      
          if(item.parent === 0) {
            filtered.push(item);
          }
        })

        return filtered;
    }
}]);

See the updated plunker: http://plnkr.co/edit/96aX0cqLT9SJX2YZquns?p=preview

For more information about filters checkout the docs

You can make your own filter in angular, you can try something like this:

  <div ng-controller="ListCtrl">
      <ul ng-repeat="category in categories | customFilter:category">
          <li>{{category.title}}</li>
      </ul>
  </div>

and the filter:

app.filter('customFilter', [function () {
    return function (items) {
        var filtered = [];
    
        angular.forEach(items, function (item) {
      
          if(item.parent === 0 && indexOf(item) < 0) {
            filtered.push(item);
          }
        })

        return filtered;
    }
}]);

See the updated plunker: http://plnkr.co/edit/96aX0cqLT9SJX2YZquns?p=preview

For more information about filters checkout the docs

Source Link
Azox
  • 1.9k
  • 2
  • 15
  • 22

You can make your own filter in angular, you can try something like this:

  <div ng-controller="ListCtrl">
      <ul ng-repeat="category in categories | customFilter:category">
          <li>{{category.title}}</li>
      </ul>
  </div>

and the filter:

app.filter('customFilter', [function () {
    return function (items) {
        var filtered = [];
    
        angular.forEach(items, function (item) {
      
          if(item.parent === 0) {
            filtered.push(item);
          }
        })

        return filtered;
    }
}]);

See the updated plunker: http://plnkr.co/edit/96aX0cqLT9SJX2YZquns?p=preview

For more information about filters checkout the docs