node.js - 未捕获的错误:[$injector:modulerr] http://errors.angularjs.org/1.7.9/$injector/moduler
问题描述
在加载我的应用程序时,我在控制台中收到上述错误。我的控制器如下所示。我是 Angular 新手,所以任何帮助都将不胜感激我正在尝试将数据表导出到 excel 中。我认为问题出在这里 angular.module('myApp','datatables', 'datatables.buttons']) 将它们包含在模块中的正确方法是什么?
查看Ctrl.js
angular.module('myApp',['datatables', 'datatables.buttons'])
.controller('ViewCtrl', function($scope, DTOptionsBuilder, DTColumnDefBuilder) {
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withDisplayLength(2)
.withDOM('pitrfl')
.withButtons([{
extend: 'excelHtml5',
}
]);
vm.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0),
DTColumnDefBuilder.newColumnDef(1).notVisible(),
DTColumnDefBuilder.newColumnDef(2).notSortable()
];
});
解决方案
验证控制台加载。如果 console.log 没有显示并且您仍然收到注入错误,那么您的问题很可能是 datatables 和 datatables.buttons。验证这些文件是否已添加到您的 index.html 文件中,位于该文件之前。
angular.module('myApp', ['datatables', 'datatables.buttons'])
.controller('ViewCtrl', function ($scope) {
console.log("Code of awesomeness");
});
如果你发现你确实看到了 console.log("Code of awesomeness"); 那么您的 $inject 问题是 DTOptionsBuilder、DTColumnDefBuilder。验证拼写。