<!DOCTYPE html>
<html>

  <head>
    <meta charset="UTF-8" />
    <title>Exemple de filtre créé : currencyFR</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="customFilterExample">
    <div ng-controller="customFilterController">
      <h4>Smartphones disponibles</h4>
      <table>
        <tbody>
          <tr>
            <th>Modèle</th>
            <th>Prix (euros)</th>
            <th>Prix (francs)</th>
          </tr>
          <tr ng-repeat="smartphone in smartphones">
            <td>{{smartphone.modele}}</td>
            <td>{{smartphone.prix | currencyFR}}</td>
            <td>{{smartphone.prix*6.55957 | currencyFR:"FF"}}</td>
          </tr>
        </tbody>
      </table>
      <em>Et on se demande pourquoi tant de gens continuent à donner des sous à Samsung et Apple... ;)</em>
    </div>
  </body>

</html>
# Exemple de filtre personnalisé
### *par TutorielAngularJS*

Exemple de filtre créé entièrement par l'utilisateur
Filtre créé :
`currencyFR`
Permet d'afficher des prix "à la façon francophone", avec le symbole après le montant.
----
Pour plus d'infos, voir [Les filtres  - Tutoriel AngularJS](http://www.tutoriel-angularjs.fr/tutoriel/2-utilisation-complete-d-angularjs/2-les-filtres#creer-son-propre-filtre)
'use strict';
angular.module('customFilterExample', [])
  .controller('customFilterController', ['$scope', function($scope) {
    $scope.smartphones = 
      [{modele:'Wiko Wax', prix:110},
       {modele:'Galaxy SIII', prix:300},
       {modele:'Galaxy SV', prix:500},
       {modele:'iPhone 5', prix:499.99},
       {modele:'iPhone 6', prix:700}];
  }])
  .filter('currencyFR', ['numberFilter', function(numberFilter){
    return function(input, symbol){
      if(isNaN(input)){
        return input;
      } else{
        symbol = symbol || "€" ;
        input = numberFilter(input,2);
        return input + ' ' + symbol;
      }
    };
  }]);