Custom Filter App

HTML

<div ng-app="myApp">
  <h1>
  Creating Custom Filter
  </h1>
  <div ng-controller="myCtrl">
    <ul>
      <li ng-repeat="p in people | filterAdults">
        {{ p.name }} ({{p.age}})
      </li>
    </ul>
  </div>
</div>

JavaScript

var app = angular.module("myApp", []);
app.controller('myCtrl', function ($scope) {
	$scope.sampleText = "my custom filter";
  $scope.people = [
  	 { name:"John", age: 23 },
     { name:"Linda", age: 19},
     { name:"Craig", age: 17 },
     { name:"Simon", age: 21},
     { name:"Mary", age: 15 }
  ];
});
app.filter('filterAdults', function () {
  return function (items) {
      var adults = [];
    	angular.forEach(items, function(item) {
  			if(item.age > 18) {
        	this.push(item)
        }
			}, adults);
    	return adults;
  };
});