angular.module('myApp', []).
  filter('censor', function() {
    return function(input, replacement) {
      var cWords = ['niedobry', 'ponury', 'mroczny'];
      var out = input;
      for(var i=0; i<cWords.length; i++){
        out = out.replace(cWords[i], replacement);
      }
      return out;
    };
  }).
  controller('myController', ['$scope', 'censorFilter', 
                              function($scope, censorFilter) {
    $scope.phrase="To jest niepoprawna fraza.";
    $scope.txt = "Kliknij, aby odfiltrować wyrazy: mroczny i ponury.";
    $scope.filterText = function(){
      $scope.txt = censorFilter($scope.txt, '<<ocenzurowane>>');
    };
  }]);