title: Angular $parse in filter
body: <p>I have like of this inside a controller,</p>
  
  <pre><code>$scope.types = Array({'name': '...', 'condition: 'type=1'}, {'name': '...', 'type=2 or type&gt;4'});
  $scope.items = Array({'id': 1, 'name': 'A', 'type': 1 }, {'id': 8, 'name': 'B', 'type': 2 }, {'id': 123, 'name': 'C', 'type': 2 });
  </code></pre>
  
  <p>I also have an <code>ng-repeat</code> loop iterating over the <code>$scope.items</code>, together with a custom filter (piped with <code>| customFilter</code>). The customFilter can access the chosen <code>$scope.types</code> and iterates over all the items from <code>$scope.items</code>. </p>
  
  <p>What I would like to do is to apply a string as a condition in order to be able to determine wether to filter this item or not, like this:</p>
  
  <pre><code>.filter('customFilter', function($parse) {
  
    return function(items, scope) {
      var filtered = [];
      if (_.isUndefined(scope.vm.type)) { // no need to filter
        return items;
      }
      var chkType = scope.vm.type.condition;
      angular.forEach(items, function(item) {
   //     var model = $parse(scope.vm.type.condition);
        var model = $parse("vm.type.condition");
        if (item.type === scope.vm.type[0]) {
          filtered.push(item);
        }
      });
      return filtered;
    } 
  })
  </code></pre>
  
  <p>Could someone help me out here, to get this to work inside a loop inside a filter, or if there's a totally different approach? Thanks!</p>