在加载我的应用程序时,在控制台中收到上述错误。我的控制器如下所示。我正在尝试将数据表导出到excel中。我认为问题出在这里angular.module('myApp','datatables','datatables.buttons'])将它们包含在模块中的正确方法是什么?
ViewCtrl.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(“令人敬畏的代码”);然后,您的$ inject问题是DTOptionsBuilder,DTColumnDefBuilder。验证拼写。