Can't bind to 'dtOptions' since it isn't a known property of 'table'.

Ali-Alrabi picture Ali-Alrabi · Sep 11, 2017 · Viewed 13.2k times · Source

I'm working to get angular way work and use this code https://l-lin.github.io/angular-datatables/#/basic/angular-way

- node version:v6.10.3
- npm version:v6.10.3
- angular version:4.3.2
- jquery version:3.2.1
- datatables version:1.10.15
- angular-datatables version:4.2.0
- angular-cli version:1.2.6

I have made this steps to fix Unexpected value "DataTablesModule" imported by the module "AppModule". Please add a @NgModule Annotation.

 1-in tsconfig.json add
"baseUrl": ".",
"paths": {
   "@angular/*": [
    "node_modules/@angular/*"
 ]
 2-in webpack.comon.js add 
  plugins: [
         new TsConfigPathsPlugin({
          configFileName: helpers.root('tsconfig.json'),
          compiler: "typescript",
        })
   ]  

but get this error

Can't bind to 'dtOptions' since it isn't a known property of 'table'. 

Can anyone help me please to fix this isuue?

Answer

Ganj Khani picture Ganj Khani · Dec 20, 2017

If you have TablesComponent, you should use this line in your tables.module.ts file:

import { DataTablesModule } from 'angular-datatables';

And add DataTablesModule to @NgModule imports.

I had error when I add these lines in appComponent, but when I import in my special module, the problem was solved.