I am trying to import a simple table using angular with jspdf-autotable. But I cant, Here is error
jspdf.plugin.autotable.js:1023 Uncaught TypeError: Cannot set property 'autoTable' of undefined
at Object.<anonymous> (jspdf.plugin.autotable.js:1023)
at __webpack_require__ (jspdf.plugin.autotable.js:39)
at jspdf.plugin.autotable.js:103
at jspdf.plugin.autotable.js:106
at webpackUniversalModuleDefinition (jspdf.plugin.autotable.js:12)
at Object../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js (jspdf.plugin.autotable.js:19)
at __webpack_require__ (bootstrap:84)
at Module../src/app/components/zone-list/zone-list.component.ts (zone-list.component.ts:12)
at __webpack_require__ (bootstrap:84)
at Module../src/app/app-routing.module.ts (app-routing.module.ts:3)
For package.json :
"jspdf": "^2.1.0",
"jspdf-autotable": "^2.3.5",
For .ts :
here is import :
import jsPDF from 'jspdf';
var autoTable = require('jspdf-autotable');
here is download function :
var head = [['ID', 'Country', 'Rank', 'Capital']]
var data = [
[1, 'Denmark', 7.526, 'Copenhagen'],
[2, 'Switzerland', 7.509, 'Bern'],
[3, 'Iceland', 7.501, 'Reykjavík'],
[4, 'Norway', 7.498, 'Oslo'],
[5, 'Finland', 7.413, 'Helsinki'],
]
const doc = new jsPDF()
autoTable(doc, {
head: head,
body: data,
didDrawCell: (data) => {
console.log(data.column.index)
},
})
doc.save('table.pdf')
Tell me what went wrong?