我正在使用OcLazyLoad在路由器中加载控制器。 这是我路由器的片段。
.state("admin.report_draft", {
url: "/report_draft",
template: "<Redirect state='admin' page='report_draft'>",
controller: "DraftReportController",
resolve: {
deps: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before',
files: [
'js/controllers/EditReportModalController.js',
'js/controllers/DraftReportController.js',
'../bower_components/angular-ui-select/dist/select.css',
'../bower_components/angular-chips/dist/main.css'
]
});
}],
},
data: {pageTitle: 'Draft Reports'},
})
EditReportModalController.js:
angular.module('MetronicApp').controller('EditReportModalController', function($scope, params){
$scope.selectedReport = params;
var url = '/admin/report/' + params.id;
var sendModalRequest = function(url, method, data) {
djangoAuth.request({
method: method,
url: url,
data: data
}).then(function(response){
console.log(response);
}, function(error){
console.log(error);
});
$state.reload();
close(null, 200);
};
$scope.saveChanges = function(published){
params['published'] = published;
sendModalRequest('PUT', url, params);
};
console.log($scope.selectedReport);
});
在DraftReportController中,我调用了ModalService来显示模态。
DraftReportController.js:
angular.module('MetronicApp').controller('DraftReportController', function($scope, $state, djangoAuth, configService, FileUploader, ModalService, EditReportModalController){
....
$scope.editDraft = function(report){
ModalService.showModal({
templateUrl: "views/modals/edit_report_draft.html",
controller: "EditReportModalController",
input:{
report: report
}
}).then(function(modal){
modal.element.modal();
})
};
....
我在这里收到错误:
未知提供者:EditReportModalControllerProvider&lt; - EditReportModalController&lt; - DraftReportController
似乎无法将EditReportModalController解析为依赖项。 你想帮助我吗?如何将DraftReportController中的EditReportModalController作为依赖项?