Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

datatables for angular4 #998

Closed
zxdmrg opened this issue Mar 29, 2017 · 16 comments
Closed

datatables for angular4 #998

zxdmrg opened this issue Mar 29, 2017 · 16 comments
Labels
Milestone

Comments

@zxdmrg
Copy link

zxdmrg commented Mar 29, 2017

Before you write your question, please take some extra time to write a good title that is short yet descriptive.

What versions you are using?

  • angular version: 4.0.0
  • jquery version: 3.2.1
  • datatables version: 1.10.13
  • angular-datatables version: 2.2.0
  • angular-MM version:

What's the problem?

Error encountered resolving symbol values statically.Calling function 'makeDecorator',

angular-datatables/node_modules/@angular/core/src/metadata/ng_module.d.ts

Can you share your code?

@illiniguy
Copy link

For now I pulled the .module.ts and directive.ts from the source on Github into my own module in my code and it works fine.

@yunClouds
Copy link

@illiniguy
Can I trouble you for more details how to solve it? thanks alot

@illiniguy
Copy link

illiniguy commented Apr 5, 2017

Just add a copy of the .directive.ts and .module.ts files to your project. Found here (for master):

https://github.com/l-lin/angular-datatables/tree/master/src

Then import that local module file instead of the angular-datatables one. Works for me until they upgrade to support v4.

@yunClouds
Copy link

yunClouds commented Apr 7, 2017

@illiniguy
First of all, Thanks alot illiniguy . I did as you said,I just cope the .directive.ts to my project,but there has some problem as shown in the figure:
error
How did you solve it?

@l-lin
Copy link
Owner

l-lin commented Apr 7, 2017

You need to add the typings of jQuery and DataTables:

npm install @types/jquery --save-dev
npm install @types/datatables.net --save-dev

@illiniguy
Copy link

Yep, apologies. I already had references to those libraries in my project, the latter before trying this library.

@l-lin
Copy link
Owner

l-lin commented Apr 22, 2017

I released the version 4.0.0.
It should be ok now. Tell me if you still have trouble using with Angular 4.x.x.

@illiniguy
Copy link

Set it up just now. Seems to be working great. Thanks for the update!

@l-lin l-lin added the Angular label Apr 23, 2017
@l-lin l-lin added this to the v4.0.0 milestone Apr 23, 2017
@l-lin l-lin closed this as completed Apr 23, 2017
@matthewhegarty
Copy link

I still get the error.
I have upgraded to angular-datatables 4.0.0 and I still get the above error. I've tried deleting node_modules, npm cache clean and then npm install.

angular version: 4.0.0
datatables version: 4.0.0
ng version: 1.0.1
node version: 6.9.5

@l-lin
Copy link
Owner

l-lin commented Apr 30, 2017

I honestly don't know why it does not work... With @angular/cli version 1.0.0, it works as expected, and just with one path, it won't work...
So you can:

  • either revert back to version 1.0.0 of angular-cli
  • either declare the DataTableModule by using forRoot():
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.forRoot()
  ],
  providers: [],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

@matthewhegarty
Copy link

Thanks for the response.

  • Using forRoot() does fix the issue.
  • Rolling back to [email protected] doesn't help - I get the same error

Otherwise, all I can do to fix is to roll back to the pre-4.0.0 version

My ng version:

$ ng version
@angular/cli: 1.0.1
node: 6.9.5
os: linux x64
@angular/common: 4.1.0
@angular/compiler: 4.1.0
@angular/core: 4.1.0
@angular/forms: 4.1.0
@angular/http: 4.1.0
@angular/platform-browser: 4.1.0
@angular/platform-browser-dynamic: 4.1.0
@angular/router: 4.1.0
@angular/cli: 1.0.1
@angular/compiler-cli: 4.1.0

@l-lin
Copy link
Owner

l-lin commented May 2, 2017

Using angular-cli 1.0.0 and angular 4.0.3 seem to work for me. Check the package.json of my demo.

@andikanugraha11
Copy link

I also experienced the same thing, after reading this issue my program can run by adding forRoot on the DataTablesModule

@LexBel-co
Copy link

i had the same issue, then i added DataTablesModule.forRoot() to my module, and fixed the issue

@AshuSingh07
Copy link

Using DataTablesModule.forRoot() fixed my issue.

Overloaded Thanks 👍

@ajsnyde
Copy link

ajsnyde commented Jul 5, 2017

Added forRoot() to line 18 of angular-datatables.module.js. Compiles now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants