ERROR TypeError: $(…).DataTable is not a function while using in angular 4

徘徊边缘 提交于 2020-01-05 08:32:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!