diff --git a/demo/angular.json b/demo/angular.json index 7009cb24d..4e7f8582b 100644 --- a/demo/angular.json +++ b/demo/angular.json @@ -34,6 +34,7 @@ "scripts": [ "node_modules/jquery/dist/jquery.js", "node_modules/tether/dist/js/tether.js", + "node_modules/materialize-css/dist/js/materialize.js", "node_modules/jszip/dist/jszip.js", "node_modules/datatables.net/js/jquery.dataTables.js", "node_modules/datatables.net-buttons/js/dataTables.buttons.js", diff --git a/demo/src/app/advanced/rerender-snippet.component.ts b/demo/src/app/advanced/rerender-snippet.component.ts index 6b2467c9c..98979c7d0 100644 --- a/demo/src/app/advanced/rerender-snippet.component.ts +++ b/demo/src/app/advanced/rerender-snippet.component.ts @@ -27,7 +27,7 @@ export class RerenderSnippetComponent { tsSnippet = `
-import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
+import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { DataTableDirective } from 'angular-datatables';
import { Subject } from 'rxjs';
@@ -35,13 +35,13 @@ import { Subject } from 'rxjs';
selector: 'app-rerender',
templateUrl: 'rerender.component.html'
})
-export class RerenderComponent implements OnInit, AfterViewInit {
+export class RerenderComponent implements AfterViewInit, OnDestroy, OnInit {
@ViewChild(DataTableDirective)
dtElement: DataTableDirective;
dtOptions: DataTables.Settings = {};
- dtTrigger: Subject<any> = new Subject();
+ dtTrigger: Subject = new Subject();
ngOnInit(): void {
this.dtOptions = {
@@ -63,6 +63,11 @@ export class RerenderComponent implements OnInit, AfterViewInit {
this.dtTrigger.next();
}
+ ngOnDestroy(): void {
+ // Do not forget to unsubscribe the event
+ this.dtTrigger.unsubscribe();
+ }
+
rerender(): void {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
// Destroy the table first
@@ -71,8 +76,7 @@ export class RerenderComponent implements OnInit, AfterViewInit {
this.dtTrigger.next();
});
}
-}
-
+}
`;
}
diff --git a/demo/src/app/advanced/rerender.component.ts b/demo/src/app/advanced/rerender.component.ts
index 6c51876be..5b2080c7b 100644
--- a/demo/src/app/advanced/rerender.component.ts
+++ b/demo/src/app/advanced/rerender.component.ts
@@ -1,4 +1,4 @@
-import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
+import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { DataTableDirective } from 'angular-datatables';
import { Subject } from 'rxjs';
@@ -6,7 +6,7 @@ import { Subject } from 'rxjs';
selector: 'app-rerender',
templateUrl: 'rerender.component.html'
})
-export class RerenderComponent implements OnInit, AfterViewInit {
+export class RerenderComponent implements AfterViewInit, OnDestroy, OnInit {
@ViewChild(DataTableDirective)
dtElement: DataTableDirective;
@@ -34,6 +34,11 @@ export class RerenderComponent implements OnInit, AfterViewInit {
this.dtTrigger.next();
}
+ ngOnDestroy(): void {
+ // Do not forget to unsubscribe the event
+ this.dtTrigger.unsubscribe();
+ }
+
rerender(): void {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
// Destroy the table first
diff --git a/demo/src/app/basic/angular-way-snippet.component.ts b/demo/src/app/basic/angular-way-snippet.component.ts
index aae4672ba..3fccc5307 100644
--- a/demo/src/app/basic/angular-way-snippet.component.ts
+++ b/demo/src/app/basic/angular-way-snippet.component.ts
@@ -37,28 +37,23 @@ export class AngularWaySnippetComponent {
tsSnippet = `
-import { Component, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Subject } from 'rxjs';
+import { Person } from '../person';
import 'rxjs/add/operator/map';
-class Person {
- id: number;
- firstName: string;
- lastName: string;
-}
-
@Component({
selector: 'app-angular-way',
templateUrl: 'angular-way.component.html'
})
-export class AngularWayComponent implements OnInit {
+export class AngularWayComponent implements OnDestroy, OnInit {
dtOptions: DataTables.Settings = {};
persons: Person[] = [];
// We use this trigger because fetching the list of persons can be quite long,
// thus we ensure the data is fetched before rendering
- dtTrigger: Subject<any> = new Subject();
+ dtTrigger: Subject = new Subject();
constructor(private http: Http) { }
@@ -76,6 +71,11 @@ export class AngularWayComponent implements OnInit {
});
}
+ ngOnDestroy(): void {
+ // Do not forget to unsubscribe the event
+ this.dtTrigger.unsubscribe();
+ }
+
private extractData(res: Response) {
const body = res.json();
return body.data || {};
diff --git a/demo/src/app/basic/angular-way.component.ts b/demo/src/app/basic/angular-way.component.ts
index 2c18f1bfa..48cd78498 100644
--- a/demo/src/app/basic/angular-way.component.ts
+++ b/demo/src/app/basic/angular-way.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Subject } from 'rxjs';
import { Person } from '../person';
@@ -9,7 +9,7 @@ import 'rxjs/add/operator/map';
selector: 'app-angular-way',
templateUrl: 'angular-way.component.html'
})
-export class AngularWayComponent implements OnInit {
+export class AngularWayComponent implements OnDestroy, OnInit {
dtOptions: DataTables.Settings = {};
persons: Person[] = [];
// We use this trigger because fetching the list of persons can be quite long,
@@ -32,6 +32,11 @@ export class AngularWayComponent implements OnInit {
});
}
+ ngOnDestroy(): void {
+ // Do not forget to unsubscribe the event
+ this.dtTrigger.unsubscribe();
+ }
+
private extractData(res: Response) {
const body = res.json();
return body.data || {};
diff --git a/demo/src/app/extensions/buttons-extension-configuration.component.ts b/demo/src/app/extensions/buttons-extension-configuration.component.ts
index e610d9ff5..1c66a34ce 100644
--- a/demo/src/app/extensions/buttons-extension-configuration.component.ts
+++ b/demo/src/app/extensions/buttons-extension-configuration.component.ts
@@ -12,9 +12,9 @@ import { Component } from '@angular/core';
- .angular-cli.json
+ angular.json
Add the dependencies in the scripts and styles attributes:
-
+
If you want to have the excel export functionnality, then you must import the jszip.js
before the buttons.html5.js
file.
`
@@ -32,28 +32,28 @@ npm install datatables.net-buttons-dt --save
npm install @types/datatables.net-buttons --save-dev
`;
- angularCliJsonSnippet = `
+ angularJsonSnippet = `
{
- "apps": [
- {
- ...
- "styles": [
- ...
- "../node_modules/datatables.net-buttons-dt/css/buttons.dataTables.css",
- ],
- "scripts": [
- ...
- "../node_modules/jszip/dist/jszip.js",
- "../node_modules/datatables.net-buttons/js/dataTables.buttons.js",
- "../node_modules/datatables.net-buttons/js/buttons.colVis.js",
- "../node_modules/datatables.net-buttons/js/buttons.flash.js",
- "../node_modules/datatables.net-buttons/js/buttons.html5.js",
- "../node_modules/datatables.net-buttons/js/buttons.print.js"
- ],
- ...
- }
- ]
+ "projects": {
+ "your-app-name": {
+ "architect": {
+ "build": {
+ "options": {
+ "styles": [
+ ...
+ "node_modules/datatables.net-buttons-dt/css/buttons.dataTables.css"
+ ],
+ "scripts": [
+ ...
+ "node_modules/jszip/dist/jszip.js",
+ "node_modules/datatables.net-buttons/js/dataTables.buttons.js",
+ "node_modules/datatables.net-buttons/js/buttons.colVis.js",
+ "node_modules/datatables.net-buttons/js/buttons.flash.js",
+ "node_modules/datatables.net-buttons/js/buttons.html5.js",
+ "node_modules/datatables.net-buttons/js/buttons.print.js"
+ ],
+ ...
}
`;
diff --git a/demo/src/app/extensions/colreorder-extension-configuration.component.ts b/demo/src/app/extensions/colreorder-extension-configuration.component.ts
index e40d5db43..40896a99b 100644
--- a/demo/src/app/extensions/colreorder-extension-configuration.component.ts
+++ b/demo/src/app/extensions/colreorder-extension-configuration.component.ts
@@ -12,9 +12,9 @@ import { Component } from '@angular/core';
Add the dependencies in the scripts and styles attributes:
- +
{
- "apps": [
- {
- ...
- "styles": [
- ...
- "../node_modules/datatables.net-colreorder-dt/css/colReorder.dataTables.css",
- ],
- "scripts": [
- ...
- "../node_modules/datatables.net-colreorder/js/dataTables.colReorder.js"
- ],
- ...
- }
- ]
+ "projects": {
+ "your-app-name": {
+ "architect": {
+ "build": {
+ "options": {
+ "styles": [
+ ...
+ "node_modules/datatables.net-colreorder-dt/css/colReorder.dataTables.css"
+ ],
+ "scripts": [
+ ...
+ "node_modules/datatables.net-colreorder/js/dataTables.colReorder.js"
+ ],
+ ...
}
`;
diff --git a/demo/src/app/extensions/responsive-extension-configuration.component.ts b/demo/src/app/extensions/responsive-extension-configuration.component.ts
index 8512d5c18..528f24971 100644
--- a/demo/src/app/extensions/responsive-extension-configuration.component.ts
+++ b/demo/src/app/extensions/responsive-extension-configuration.component.ts
@@ -12,9 +12,9 @@ import { Component } from '@angular/core';
Add the dependencies in the scripts and styles attributes:
- +
{
- "apps": [
- {
- ...
- "styles": [
- ...
- "../node_modules/datatables.net-responsive-dt/css/responsive.dataTables.css",
- ],
- "scripts": [
- ...
- "../node_modules/datatables.net-responsive/js/dataTables.responsive.js"
- ],
- ...
- }
- ]
+ "projects": {
+ "your-app-name": {
+ "architect": {
+ "build": {
+ "options": {
+ "styles": [
+ ...
+ "node_modules/datatables.net-responsive-dt/css/responsive.dataTables.css"
+ ],
+ "scripts": [
+ ...
+ "node_modules/datatables.net-responsive/js/dataTables.responsive.js"
+ ],
+ ...
}
`;
diff --git a/demo/src/app/extensions/select-extension-configuration.component.ts b/demo/src/app/extensions/select-extension-configuration.component.ts
index c7b495db7..8f83955a7 100644
--- a/demo/src/app/extensions/select-extension-configuration.component.ts
+++ b/demo/src/app/extensions/select-extension-configuration.component.ts
@@ -12,9 +12,9 @@ import { Component } from '@angular/core';
Add the dependencies in the scripts and styles attributes:
- +
{
- "apps": [
- {
- ...
- "styles": [
- ...
- "../node_modules/datatables.net-select-dt/css/select.dataTables.css",
- ],
- "scripts": [
- ...
- "../node_modules/datatables.net-select/js/dataTables.select.js"
- ],
- ...
- }
- ]
+ "projects": {
+ "your-app-name": {
+ "architect": {
+ "build": {
+ "options": {
+ "styles": [
+ ...
+ "node_modules/datatables.net-select-dt/css/select.dataTables.css"
+ ],
+ "scripts": [
+ ...
+ "node_modules/datatables.net-select/js/dataTables.select.js"
+ ],
+ ...
}
`;
diff --git a/demo/src/app/getting-started.component.html b/demo/src/app/getting-started.component.html
index 26f167734..2819f8a4a 100644
--- a/demo/src/app/getting-started.component.html
+++ b/demo/src/app/getting-started.component.html
@@ -35,9 +35,9 @@ Add the dependencies in the scripts and styles attributes:
- +
{
- "apps": [
- {
- ...
- "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"
- ],
- ...
- }
- ]
+ "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"
+ ],
+ ...
}
`;