我的代码就像这样
controller.js
angular.module('RateRequestApp.controllers', []).controller('ReadOnlyController', [
'$scope', 'rateRequestService', 'rePrintAllService', 'rePrintService', 'voidShipmentService', 'updateTruckNoService', 'messageModalService', '$modal', 'FileUploader',
function ($scope, rateRequestService, rePrintAllService, rePrintService, voidShipmentService, updateTruckNoService, messageModalService, $modal, FileUploader) {
// my logic
}
]);
angular.module('RateRequestApp.controllers').controller('GenericRateRequestCtrl', function ($scope, addressService) {
// my logic
});
app.js
angular.module('RateRequestApp', [
'RateRequestApp.services',
'RateRequestApp.controllers',
'ui.bootstrap',
'angular-loading-bar',
'textAngular',
'angularFileUpload'
]);
HTML
<body ng-app="RateRequestApp" ng-controller="GenericRateRequestCtrl">
</body>
一切看起来都没问题,但这会引发错误
Error: [ng:areq] Argument 'GenericRateRequestCtrl' is not a function, got undefined
任何人都可以指出我做错了吗?
答案 0 :(得分:0)
在javascript代码中,从RateRequestApp.controllers
更改为RateRequestApp
实施例
angular.module('RateRequestApp', []).controller('ReadOnlyController', [
'$scope', 'rateRequestService', 'rePrintAllService', 'rePrintService', 'voidShipmentService', 'updateTruckNoService', 'messageModalService', '$modal', 'FileUploader',
function ($scope, rateRequestService, rePrintAllService, rePrintService, voidShipmentService, updateTruckNoService, messageModalService, $modal, FileUploader) {
// my logic
}
]);
angular.module('RateRequestApp').controller('GenericRateRequestCtrl', function ($scope, addressService) {
// my logic
});
演示:
答案 1 :(得分:-1)
请参阅here
使用您的模块创建变量并在以下之后使用它:
var appCtrls = angular.module('RateRequestApp.controllers',[]);
appCtrls.controller('ReadOnlyController', [
'$scope', 'rateRequestService', 'rePrintAllService', 'rePrintService', 'voidShipmentService', 'updateTruckNoService', 'messageModalService', '$modal', 'FileUploader',
function ($scope, rateRequestService, rePrintAllService, rePrintService, voidShipmentService, updateTruckNoService, messageModalService, $modal, FileUploader) {
// my logic
}
]);
appCtrls.controller('GenericRateRequestCtrl', function ($scope, addressService) {
// my logic
});