2017-02-14 118 views
1

我在注入资源时遇到问题。

Error: [$injector:unpr] Unknown provider: $resourseProvider <- $resourse <- Phone

这是我的代码

的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' 
]); 

电话list.module.js

'use strict'; 

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

电话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 
     } 
    }); 
    } 
    ]); 

回答

0

修复很简单。你已经在phone.factory.js

'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 
     } 
    }); 
    } 
]); 
+0

哦......是的拼写单词resource不正确。谢谢 –

相关问题