问题
I'm getting ERROR TypeError: $(...).DataTable is not a function while using in angular 4.
Any suggestions for resolving this issue.
回答1:
If you are importing jQuery as a local lib, in your *component.ts file, like:
import * as jquery from 'jquery'
remove that line and treat it as a global library:
declare var jquery: any;
or
declare var $: any;
or just add one of that two lines to src/typings.d.ts
回答2:
Still I did not get datable(datatable is not a function) after adding
import * as $ from 'jquery';
Then I added below code also it's working now:
import 'datatables.net';
If you still did receive an error, try with the below also:
import 'datatables.net-bs4';
来源:https://stackoverflow.com/questions/47619179/error-typeerror-datatable-is-not-a-function-while-using-in-angular-4