尝试使用angular-datatables时,我收到了下一个错误。
我的所有文件夹都包含推荐的设置,我正在关注网站http://l-lin.github.io/angular-datatables/archives/#/gettingStarted
中的示例错误位于angular-datatables.js的下一行:
export { DataTablesModule } from './angular-datatables.module';
export { DataTableDirective } from './angular-datatables.directive';
HTML:
<div ng-app='clinang' ng-controller="pacientesCtrl">
<h4>Cadastro de pacientes</h4>
<table datatable="" dt-options="pacientesCtrl.dtOptions" dt-columns="pacientesCtrl.dtColumns" class="row-border hover"></table>
</div>
这是我的JS:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="files/lib/bootstrap/bootstrap.js"></script>
<!-- Latest compiled and minified JavaScript -->
<link rel="stylesheet" href="files/lib/bootstrap/bootstrap.css" >
<script src="files/lib/angular/angular.js"></script>
<script src="files/lib/angular-datatables/angular-datatables.js"></script>
<script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<script src="files/lib/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>
<link href="https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="files/lib/angular-datatables/angular-datatables.css">
<script src="files/js/controllers/pacientesCtrl.js"></script>
<script type="text/javascript">
angular.module('clinang',[]);
angular.module('clinang', ['ui.bootstrap','datatables']);
</script>
pacientesCtrl.js:
angular.module('clinang').controller('pacientesCtrl', function (DTOptionsBuilder, DTColumnBuilder) {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromSource('/getdadospac/?oper=S')
.withPaginationType('full_numbers');
vm.dtColumns = [
DTColumnBuilder.newColumn('pront').withTitle('pront'),
DTColumnBuilder.newColumn('nome').withTitle('Nome'),
DTColumnBuilder.newColumn('endereco').withTitle('Endereço').notVisible()
];
});
错误:
angular-datatables.js:12 Uncaught SyntaxError: Unexpected token export
angular.js:4759 Uncaught Error: [$injector:modulerr] Failed to instantiate module clinang due to:
Error: [$injector:modulerr] Failed to instantiate module datatables due to:
Error: [$injector:nomod] Module 'datatables' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.1/$injector/nomod?p0=datatables
at http://127.0.0.1:8888/files/lib/angular/angular.js:68:12
at http://127.0.0.1:8888/files/lib/angular/angular.js:2183:17
at ensure (http://127.0.0.1:8888/files/lib/angular/angular.js:2107:38)
at module (http://127.0.0.1:8888/files/lib/angular/angular.js:2181:14)
at http://127.0.0.1:8888/files/lib/angular/angular.js:4736:22
at forEach (http://127.0.0.1:8888/files/lib/angular/angular.js:357:20)
at loadModules (http://127.0.0.1:8888/files/lib/angular/angular.js:4720:5)
at http://127.0.0.1:8888/files/lib/angular/angular.js:4737:40
at forEach (http://127.0.0.1:8888/files/lib/angular/angular.js:357:20)
at loadModules (http://127.0.0.1:8888/files/lib/angular/angular.js:4720:5)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=datatables&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'datatables'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.6.1%2F%24injector%2Fnomod%3Fp0%3Ddatatables%0A%20%20%20%20at%20http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A68%3A12%0A%20%20%20%20at%20http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A2183%3A17%0A%20%20%20%20at%20ensure%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A2107%3A38)%0A%20%20%20%20at%20module%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A2181%3A14)%0A%20%20%20%20at%20http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A4736%3A22%0A%20%20%20%20at%20forEach%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A357%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A4720%3A5)%0A%20%20%20%20at%20http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A4737%3A40%0A%20%20%20%20at%20forEach%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A357%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2F127.0.0.1%3A8888%2Ffiles%2Flib%2Fangular%2Fangular.js%3A4720%3A5)
at http://127.0.0.1:8888/files/lib/angular/angular.js:68:12
at http://127.0.0.1:8888/files/lib/angular/angular.js:4759:15
at forEach (http://127.0.0.1:8888/files/lib/angular/angular.js:357:20)
at loadModules (http://127.0.0.1:8888/files/lib/angular/angular.js:4720:5)
at http://127.0.0.1:8888/files/lib/angular/angular.js:4737:40
at forEach (http://127.0.0.1:8888/files/lib/angular/angular.js:357:20)
at loadModules (http://127.0.0.1:8888/files/lib/angular/angular.js:4720:5)
at createInjector (http://127.0.0.1:8888/files/lib/angular/angular.js:4642:19)
at doBootstrap (http://127.0.0.1:8888/files/lib/angular/angular.js:1838:20)
at bootstrap (http://127.0.0.1:8888/files/lib/angular/angular.js:1859:12)
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=clinang&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20Failed%20to%20instantiat......
答案 0 :(得分:2)
您可以在源代码中编辑/angular-datatables/dist/angular-datatables.js.map,在这里您可以找到对typescript文件的调用,如果您将相同的文件作为.js这个更改放到下一行但是出现同样的错误,我也有类似的问题......
答案 1 :(得分:1)
这是正确的顺序:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="../../datatables.min.js"></script>
<script src="/../bootstrap/js/bootstrap.min.js"></script>
<script src="/../angular/angular.min.js"></script>
<script src="/../angular-datatables/demo/src/archives/dist/angular-datatables.min.js"></script>
这是正确的顺序,请记住我使用的路线与您的路线不同,因此您必须按照指示的顺序验证所提到的文件是否存在。
对于angular-datatables.min.js文件,您可以将路径更改为路径:/angular-datatables/angular-datatables.min.js
,以防万一它不起作用,您可以使用我之前指出的路径。我希望这可以帮助他们:)
答案 2 :(得分:0)
尝试使用版本angular-datatables 0.6.2:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.6.2/angular-datatables.min.js"></script>