코드에서 각도 데이터 테이블을 사용하는 중에 TypeError가 발생합니다. 이 지침에서DataTable이 함수가 아닙니다. 각도 4에 각도 데이터 테이블을 사용하는 중에 TypeError가 발생합니다.
ERROR TypeError: $(...).DataTable is not a function
at angular-datatables.directive.js:38
코드는 다음과 같습니다
DataTableDirective.prototype.displayTable = function() {
var _this = this;
this.dtInstance = new Promise(function (resolve, reject) {
Promise.resolve(_this.dtOptions).then(function (dtOptions) {
// Using setTimeout as a "hack" to be "part" of NgZone
setTimeout(function() {
//Error in this line
var dt = $(_this.el.nativeElement).DataTable(dtOptions);
resolve(dt);
});
});
});
};
문제가 여기에 무엇입니까? 라이브러리 및 종속성을 다음에 의해 설치했습니다 :
npm install jquery --save
npm install datatables.net --save
npm install datatables.net-dt --save
npm install angular-datatables --save
npm install @types/jquery --save-dev
npm install @types/datatables.net --save-dev
어떤 생각입니까?
업데이트 :
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"allowSyntheticDefaultImports": true
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
및 tsconfig.json : 여기 내 tsconfig.app.json입니다
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"allowSyntheticDefaultImports": true,
"paths": {
"@angular/*": [
"../node_modules/@angular/*"
]
}
}
}
빈 유형 array ("유형": [])가있는 경우 tsconfig.json 및 해당 하위 파일 (예 : tsconfig.app.json)을 확인하십시오. – omeralper
나는 그것을 가지고 있었지만 나는 그것을 제거했지만 변화는 없었다. – Burak
angular-cli.json 파일에 모든 파일을 추가 했습니까? – omeralper