我遇到以下错误:
angular.js:14199错误:[$ injector:unpr]未知提供程序:ComplianceServiceProvider <-ComplianceService <-ComplianceController
在以下Controller
中:
(function () {
angular.module('tasksModule')
.controller('ComplianceController', ComplianceController)
function ComplianceController($log, configService, scheduleService, dateTimeService, storeService,
areaService, complianceService) {
..... some code here
}
})();
以及以下Service
:
(function(){
angular.module('tasksModule')
.service('complianceService', ComplianceService)
function ComplianceService($log, $tasksApi) {
var vm = this
vm.get = get
function get(filter){
$log.debug('Service - ComplianceService - get')
return $tasksApi
.then(function(v){
return v.$request().$get('compliance', filter)
})
.then(Compliance)
}
function Compliance(resource) {
return {
resource : resource,
tasks : resource.tasks
}
}
}
})
但是我遇到了injector
错误,为什么?有人可以帮助我吗?
答案 0 :(得分:0)
调用功能:
(function(){
angular.module('tasksModule')
.service('complianceService', ComplianceService)
function ComplianceService($log, $tasksApi) {
var vm = this
vm.get = get
function get(filter){
$log.debug('Service - ComplianceService - get')
return $tasksApi
.then(function(v){
return v.$request().$get('compliance', filter)
})
.then(Compliance)
}
function Compliance(resource) {
return {
resource : resource,
tasks : resource.tasks
}
}
}
̶}̶)̶
//IMPORTANT - Invoke the function
})()
调用该函数很重要。
有关更多信息,请参见