2013-04-29 24 views
1

獲取錯誤:Uncaught Error: Unknown provider: $resource from accessServices。有誰知道什麼可能是錯的?

angular.module('accessServices', ['ngResource']). 

    config(function ($resource) { 
    this.accesses = ['createuser']; 
    this.AclResource = $resource('/api/v1', {}, { 
     list: {method: 'GET', params: {}, isArray: true} 
    }); 
    ... 

回答

1

config method是配置模塊,並建立了供應商,你不能注入$resource服務(但你可以注入$resourceProvider)。無論如何,它看起來像你正在創建一個服務,所以你可能想使用工廠方法:

angular.module('accessServices', ['ngResource']) 
    .factory('AclResource',function ($resource) { 
    ...