AngularJS scope Example

HTML

<div ng-app="myapp" >
   <div ng-controller="ctrl1"> 
       <div ng-repeat="hash in hashes | filter: {type:'foo'}">
           {{hash.a}}
       </div>
       second list:
          <div ng-repeat="hash in hashes | filter: filterArray">
           {{hash.a}}
       </div>


</div>

JavaScript

var myapp = angular.module("myapp", []);


myapp.controller("ctrl1", function ($scope) {
    
  $scope.hashes = [
  {
      "type": "foo"
      , "a": "1"
  }
  , {
      "type": "foo"
   , "a": "2"
  }
  , {
      "type": "bar"
    , "a": "3"
  }
  , {
      "type": "quz"
    , "a": "4"
  }
      , {
      "type": "quz"
    , "a": "5"
  }
];
    
    $scope.types = ['foo','quz'];
    
    $scope.filterArray = function(hash) {
        return ($scope.types.indexOf(hash.type) !== -1);
    };

});