title: Filter with ng-repeat
body: <p>I'm trying to make a filter with the <code>angularJs</code> <strong>directive</strong> called <code>ng-repeat</code> the filter works as follows: 
  When you click on the <code>checkbox</code> filters in an array the items that have <code>offers</code>, I'm using a function to filter, I think there is a better way to do it without so much code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('myApp', []);
  app.controller('myCtrl', function($scope, $http, $document) {
  
      $scope.items = [
          {
              id: 0,
              description: "Primer Item 1",
              offers: [
                  {
                      id: 0,
                      name: "Casa"
                  }
              ]
          },
          {
              id: 1,
              description: "Segundo Item 2"
          },
          {
              id: 2,
              description: "Tercer Item 3"
          },
          {
              id: 3,
              description: "Cuarto Item 4"
          },
          {
              id: 4,
              description: "Quinto Item 5"
          },
          {
              id: 5,
              description: "Sexto Item 5",
              offers: [
                  {
                      id: 1,
                      name: "Bodega"
                  }
              ]
          },
          {
              id: 6,
              description: "Septimo Item 6"
          },
          {
              id: 7,
              description: "Octavo Item 7"
          },
          {
              id: 8,
              description: "Noveno Item 8"
          },
          {
              id: 9,
              description: "Decimo Item 9"
          }
      ];
  
      $scope.filterItem = function() {
          if (!$scope.itemOffer){
              $scope.filterOffer = function(item) {
                  return item.offers &amp;&amp; item.offers.length &gt; 0;
              };
              $scope.itemOffer = true;
          } else {
              $scope.filterOffer = function(item) {
                  return item;
              };
              $scope.itemOffer = false;
          }
      };
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body ng-app="myApp" ng-controller="myCtrl"&gt;
          &lt;input type="checkbox" name="filter" value="propertyOffer" ng-model="propertyOffer" ng-click="filterItem()"&gt;Item with offert
          &lt;div ng-repeat="item in items | filter: filterOffer track by $index"&gt;
              {{ item }}
          &lt;/div&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>