angulaire: Erreur: Fournisseur inconnu pendant module.config ()

- Je obtenir Uncaught Error: Unknown provider: testProvider from myApp dans le code ci-dessous:

test est un fournisseur personnalisé.

angular.module('myApp', [])
  .config(function (testProvider) {
    testProvider.setPrefix("works: ");
  });

Code complet est ici:

angular.module('myApp', [])
  .config(function (testProvider) {
    testProvider.setPrefix("works: ");
  });


angular.module('myApp')
  .provider ("test", function () {
    var prefix;
    this.setPrefix = function(p) {
      prefix = p;
    }

    this.$get = function () {
      return {
        log: function(msg) {
          console.log (prefix + msg);
        }
      }
    }
  });

angular.module('myApp')
  .controller ("myCtrl", function($scope, test) {
    $scope.$watch ('myModel', function (newval) {
      test.log(newval);
    })
  });

Plunker lien: http://plnkr.co/edit/zcIHRn?p=preview

source d'informationauteur Krishna Srinivas