<!DOCTYPE html>
<html>

  <head>
    <meta charset="UTF-8" />
    <title>Exemple 3 du filtre filter</title>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
    <script src="script.js"></script>
  </head>

  <body ng-app="filterExample">
    <div ng-controller="filterController">
      <p>
        Âge minimum requis : 
        <input type="text" ng-model="minAge" />
      </p>
      <table>
        <tbody>
          <tr>
            <th>Nom</th>
            <th>Âge</th>
            <th>Téléphone</th>
          </tr>
          <tr ng-repeat="ami in amis | filter:searchFunction">
            <td>{{ami.nom}}</td>
            <td>{{ami.age}}</td>
            <td>{{ami.tel}}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>

</html>
# Exemple 3 du filtre filter
### *par TutorielAngularJS*

Exemple basique en utilisant une fonction pour filtrer le tableau. 
Prédicat utilisé :
`searchFunction(minAge)`
----
Pour plus d'infos, voir [Les filtres  - Tutoriel AngularJS](http://www.tutoriel-angularjs.fr/tutoriel/2-utilisation-complete-d-angularjs/2-les-filtres#filter)
'use strict';
angular.module('filterExample', [])
  .controller('filterController', ['$scope', function($scope) {
    $scope.amis =
        [{nom:'John', tel:'01-23-45-67-89', age:10},
         {nom:'Mary', tel:'02-34-56-78-91', age:19},
         {nom:'Mike', tel:'03-45-67-89-12', age:21},
         {nom:'Adam', tel:'04-56-78-91-23', age:35},
         {nom:'Julie', tel:'05-67-89-12-34', age:29}];
    $scope.minAge = 0;
    $scope.searchFunction = function(ami){
      return ami.age >= $scope.minAge;
    };
  }]);