3

I am not able to include DataTableModule into our Angular 6 project with datatable. I am using angular cli 6 with datatable. My code is showing error that cannot find module DataTablesModule. I have installed all packages related to datatable and jquery. It is also displaying into node_modules folder but not able to add into app.module.ts.

I am attaching the screenshot below:

Here is my code.

Here is my code

Getting this error in browser

enter image description here

  • have you included the file path in the angular.json? – Exterminator Oct 12 '18 at 11:08
  • yes I have included – deepak bhardwaj Oct 12 '18 at 12:00
2

Maybe you are missing any dependency. Follow the steps given in this documentation Angular Datatables

1: Install all the dependencies

  • 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

2: Add all the dependencies in angular.json

{
  "projects": {
    "your-app-name": {
      "architect": {
        "build": {
          "options": {
            "styles": [
              "node_modules/datatables.net-dt/css/jquery.dataTables.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.js",
              "node_modules/datatables.net/js/jquery.dataTables.js"
            ],
            ...
}

3: Import in app-module

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { DataTablesModule } from 'angular-datatables';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    DataTablesModule
  ],
  providers: [],
  bootstrap: [ AppComponent ]
})
export class AppModule {}
| improve this answer | |
  • 1
    followed all these steps, but still angular datatable is showing error – deepak bhardwaj Oct 12 '18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.