Javascript 未定义平均堆栈角度控制器
我很难找出为什么我的控制器没有在我的平均堆栈中定义。其他所有控制器都工作正常Javascript 未定义平均堆栈角度控制器,javascript,angularjs,express,mean-stack,Javascript,Angularjs,Express,Mean Stack,我很难找出为什么我的控制器没有在我的平均堆栈中定义。其他所有控制器都工作正常 Error: Argument 'ReportsController' is not a function, got undefined at assertArg (http://localhost:3000/lib/angular/angular.js:1039:11) at assertArgFn (http://localhost:3000/lib/angular/angular.js:1049:3).....
Error: Argument 'ReportsController' is not a function, got undefined
at assertArg (http://localhost:3000/lib/angular/angular.js:1039:11)
at assertArgFn (http://localhost:3000/lib/angular/angular.js:1049:3).....
app.js
window.app = angular.module('mean', ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles', 'mean.reports', 'angularFileUpload']);
angular.module('mean.system', []);
angular.module('mean.articles', []);
angular.module('mean.songs', []);
angular.module('mean.reports', []);
reports.js
angular.module('mean.reports').
controller('ReportsController',
['$scope', '$routeParams', '$location', 'Global', 'Reports',
function ($scope, $routeParams, $location, Global, Reports) {
$scope.global = Global;
$scope.find = function() {
Reports.query(function(reports) {
$scope.reports = reports;
}
);
};
}
]
);
routes.js
//report routes
var reports = require('../app/controllers/reports');
app.get('/reports', reports.all);
app.post('/reports', auth.requiresLogin, reports.create);
app.get('/reports/:reportId', reports.show);
app.put('/reports/:reportId', auth.requiresLogin, auth.report.hasAuthorization, reports.update);
app.del('/reports/:reportId', auth.requiresLogin, auth.report.hasAuthorization, reports.destroy);
//Finish with setting up the reportId param
app.param('reportId', reports.report);
编辑:已修复-请参阅注释由于
reports.js
中的控制器定义存在错误,因此出现该错误:缺少)
,}
,]
因此,角度函数assertArg()
不会将其识别为函数,从而引发错误
它应该是这样的(我展开它以使错误更容易):
angular.module('mean.reports')。
控制器('ReportsController',
[“$scope”、“$routeParams”、“$location”、“Global”、“Reports”,
功能($scope、$routeParams、$location、Global、Reports){
$scope.global=全局;
$scope.find=函数(){
报表查询(函数(报表){
$scope.reports=报告;
}
);//您得到该错误是因为reports.js中的控制器定义有错误:缺少)
,,,]
因此,角度函数assertArg()
不会将其识别为函数,从而引发错误
它应该是这样的(我展开它以使错误更容易):
angular.module('mean.reports')。
控制器('ReportsController',
[“$scope”、“$routeParams”、“$location”、“Global”、“Reports”,
功能($scope、$routeParams、$location、Global、Reports){
$scope.global=全局;
$scope.find=函数(){
报表查询(函数(报表){
$scope.reports=报告;
}
);//我为您展开了它-它与您的代码相同,只是末尾没有额外的括号。我仍然收到相同的错误我为您展开了它-它与您的代码相同,只是末尾没有额外的括号。我仍然收到相同的错误显然我没有将应用程序服务和控制器添加到我的脚上.jade文件。那修复了所有没有更改控制器代码的问题?是的,我不需要更改控制器代码显然我没有将应用程序服务和控制器添加到我的“foot.jade”文件。那修复了所有没有更改控制器代码的问题?是的,我不需要更改控制器代码
angular.module('mean.reports').
controller('ReportsController',
['$scope', '$routeParams', '$location', 'Global', 'Reports',
function ($scope, $routeParams, $location, Global, Reports) {
$scope.global = Global;
$scope.find = function() {
Reports.query(function(reports) {
$scope.reports = reports;
}
); // <-- missing
}; // <-- missing
} // <-- misssing
] // <-- missing
);
}; // is seems that should be deleted