2016-11-22 18 views
0

こんにちは、私は"unknown provider"を解決しようとするいくつかの問題を持っているあなたは間違って何が起こっているかを見つけるために私を助けるかもしれないように、私はいくつかのコードを共有:index.module.jsでAngular.provider不明

angular 
    .module('ngNewDrupal', ['ng', 'ngResource']) 
    .provider('$newDrupal', function() { 
    var provider = this; 
    this.defaults = { [...] 
    }; 
    this.$get = ['$log', '$resource', function ($log, $resource) { 
     var forEach = angular.forEach; 
     function getResource(name, params) { 
     /*switch (name) { 
     }*/ 
     } 
     function getRoute(url) { 
     return provider.defaults.host + url; 
     } 
     var NewDrupal = function() { 
     }; 
     [...] 
     return NewDrupal; 
    }]; 
    }); 
})(window, window.angular); 

をI私は、例えば

angular 
    .module('app') 
    .component('rendition', rendition()); 
    function rendition() { 
    return { 
     templateUrl: 'app/components/rendition/rendition.html', 
     controller: renditionController, 
     controllerAs: 'rd' 
    }; 
    function renditionController($log, $newDrupal, $stateParams, $http) { 
     var rd = this; 
     var Drupal = new $newDrupal(); 

を入れて、私のxxx.components.jsの中へ

angular 
    .module('app', [ 

にngNewDrupalを追加しました最終的に私は

angular 
    .module('app') 
    .config(config); 
    function config($newDrupal) { 
    $newDrupal.defaults.actions.getMyPublication = { 
    webservice: { url: '/export_rest/my_publication' }, 
    type: 'GET', 
    params: { 
     _format: 'json', 
     cache: true, 
     isArray: true 
    } 
    }; 

LIKE「xxx.config.js」を介して私の$ newDrupalにいくつかのアクションを追加しかし、それは私が送信されます。

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: 
Error: [$injector:unpr] Unknown provider: $newDrupal 
http://errors.angularjs.org/1.5.8/$injector/unpr?p0=%24newDrupal 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:68:12 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:4511:19 
    at getService (http://192.168.50.100:3000/bower_components/angular/angular.js:4664:39) 
    at injectionArgs (http://192.168.50.100:3000/bower_components/angular/angular.js:4688:58) 
    at Object.invoke (http://192.168.50.100:3000/bower_components/angular/angular.js:4710:18) 
    at runInvokeQueue (http://192.168.50.100:3000/bower_components/angular/angular.js:4611:35) 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:4620:11 
    at forEach (http://192.168.50.100:3000/bower_components/angular/angular.js:321:20) 
    at loadModules (http://192.168.50.100:3000/bower_components/angular/angular.js:4601:5) 
    at createInjector (http://192.168.50.100:3000/bower_components/angular/angular.js:4523:19) 
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=app&p1=Error%3A%20%…92.168.50.100%3A3000%2Fbower_components%2Fangular%2Fangular.js%3A4523%3A19) 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:68:12 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:4511:19 
    at getService (http://192.168.50.100:3000/bower_components/angular/angular.js:4664:39) 
    at injectionArgs (http://192.168.50.100:3000/bower_components/angular/angular.js:4688:58) 
    at Object.invoke (http://192.168.50.100:3000/bower_components/angular/angular.js:4710:18) 
    at runInvokeQueue (http://192.168.50.100:3000/bower_components/angular/angular.js:4611:35) 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:4620:11 
    at forEach (http://192.168.50.100:3000/bower_components/angular/angular.js:321:20) 
    at loadModules (http://192.168.50.100:3000/bower_components/angular/angular.js:4601:5) 
    at createInjector (http://192.168.50.100:3000/bower_components/angular/angular.js:4523:19) 
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=app&p1=Error%3A%20%…92.168.50.100%3A3000%2Fbower_components%2Fangular%2Fangular.js%3A4523%3A19) 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:68:12 
    at http://192.168.50.100:3000/bower_components/angular/angular.js:4640:15 
    at forEach (http://192.168.50.100:3000/bower_components/angular/angular.js:321:20) 
    at loadModules (http://192.168.50.100:3000/bower_components/angular/angular.js:4601:5) 
    at createInjector (http://192.168.50.100:3000/bower_components/angular/angular.js:4523:19) 
    at doBootstrap (http://192.168.50.100:3000/bower_components/angular/angular.js:1758:20) 
    at bootstrap (http://192.168.50.100:3000/bower_components/angular/angular.js:1779:12) 
    at angularInit (http://192.168.50.100:3000/bower_components/angular/angular.js:1664:5) 
    at HTMLDocument.<anonymous> (http://192.168.50.100:3000/bower_components/angular/angular.js:31763:5) 
    at fire (http://192.168.50.100:3000/bower_components/jquery/dist/jquery.js:3187:31) 

私が変更され、どこするために必要なものを見つけることができませんでした。

+0

完全なエラースタックを取得できますか? – trichetriche

+0

提案された編集をありがとう、エラーを更新しました。 – Antoine

+0

これを実行する前にいくつかの小型化装置を使用していますか? –

答えて

0

正しい答えは、各xxx.config.jsファイルに

function config($newDrupalProvider)

function config($newDrupal)

を変更することでした。