Stack Exchange
Angular Filter JSON by Categories
I would like to filter my companies with specific Categories.
On the right side of my website, I have several Checkboxes with the categories.
When I select a category, angular should filter the companies depend on these categories.
My Categories:
<div class="checkbox m-10" ng-repeat="e_category in e_categories | filter:e_categoriesFilter">
   <label>
      <input type="checkbox" ng-model="e_category.checked" ng-click='filterByECategories(e_category)' value='@{{ e_category.id }}'>
      <i class="input-helper"></i>
      @{{ e_category.name }}
  </label>
</div>

My Companies: (Should be filtered)
<div class="row multi-columns-row">
    <div class="col-md-12 col-sm-6 col-md-4 col-lg-3" ng-repeat="company in companies | orderBy:'created_at':true">
        <div class="card profile-view" style="height: 365px;" >
            <a href="#/company/@{{ company.id }}">
                <div class="pv-header" style="background-image: url('@{{ company.profile_image_url }}');">
                    <img src="@{{ company.profile_image_url }}" class="pv-main">
                </div>

                <div class="pv-body">
                    <a href="#/company/@{{ company.id }}">
                        <h2>@{{ company.name | limitTo: 15 }}</h2>
                    </a>
                    <p>@{{ company.short_description | limitTo: 110 }}</p>
                </div>
            </a>
        </div>
    </div>
</div>

The selected Checkboxes are saved in a array with the Object of the Category. Like so:

[{"id":1,"name":"Digital Banking Produkte","checked":true},{"id":2,"name":"Digitale Marktplätze","checked":true},{"id":4,"name":"e & m - Payment","checked":true}]

The JSON of the Companies looks so:

How can i filter the Categories in this Company?
Thank u!

Give us the source code of filterByECategories(e_category) please

Post an Minimal, Complete and Verifiable Example (MCVE).

$scope.filterByECategories = function(e_category) {             var i = $.inArray(e_category, $scope.selectedECategories);             if (i > -1) {                 $scope.selectedECategories.splice(i, 1);             } else {                 $scope.selectedECategories.push(e_category);             }             return $scope.selectedECategories;         };
