错误:[$ injector:unpr]未知提供商:$ resourseProvider< - $ resourse< - Phone Angular factory

时间:2017-02-14 22:38:17

标签: javascript angularjs

注入资源时遇到问题。

  

错误:[$ injector:unpr]未知提供商:$ resourseProvider< - $ resourse< - 电话

这是我的代码

index.html

     <script src="bower_components/angular/angular.js"></script>
     <script src="bower_components/angular-resource/angular-resource.js"></script>  
     <script src="core/phone.module.js"></script>
     <script src="core/phone.factory.js"></script>
     <script src="phone-list/phone-list.module.js"></script>
     <script src="phone-list/phone-list.component.js"></script>
     <script src="app.module.js"></script>

app.module.js

'use strict';

angular.module('phoneApp', [
  'phoneList',  
  'getphone'
]);

phone-list.module.js

'use strict';

angular.module('phoneList', ['getphone']);

phone-list.component.js

'use strict';

angular.
module('phoneList').
component('phoneList', {
  templateUrl: 'phone-list/phone-list.template.html',
  controller: ['$http', '$scope', 'Phone',
  function PhoneListController($http, $scope, Phone){
    var self = this;
    $scope.search = {};
    .....

phone.module.js

'use strict';

angular.module('getphone', ['ngResource']);

phone.factory.js

'use strict';

angular.
module('getphone').
factory('Phone', ['$resourse',
  function($resourse) {
    return $resourse('phone/:phoneId.json', {}, {
      query: {
        methode: 'GET',
        params: {phoneId: 'phones'},
        isArray: true
      }
    });
  }
  ]);

1 个答案:

答案 0 :(得分:0)

修复很简单。您在 phone.factory.js

中错误拼写了单词resource
'use strict';
angular.
module('getphone').
factory('Phone', ['$resourse',  // should be resource
  function($resourse) {
    return $resourse('phone/:phoneId.json', {}, {
      query: {
        methode: 'GET',
        params: {phoneId: 'phones'},
        isArray: true
      }
    });
  }
]);