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

Commit c9278a5

Browse files
committed
1 parent e49db09 commit c9278a5

17 files changed

+44
-48
lines changed

demo/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@
3939
"devDependencies": {
4040
"@angular/cli": "1.0.0-rc.1",
4141
"@angular/compiler-cli": "2.4.8",
42+
"@types/datatables.net": "~1.10.1",
4243
"@types/jasmine": "2.5.38",
44+
"@types/jquery": "^2.0.41",
4345
"@types/node": "~6.0.60",
4446
"codelyzer": "~2.0.0-beta.4",
4547
"jasmine-core": "~2.5.2",
4648
"jasmine-spec-reporter": "~3.2.0",
4749
"karma": "~1.4.1",
4850
"karma-chrome-launcher": "~2.0.0",
4951
"karma-cli": "~1.0.1",
52+
"karma-coverage-istanbul-reporter": "^0.2.0",
5053
"karma-jasmine": "~1.1.0",
5154
"karma-jasmine-html-reporter": "^0.2.2",
52-
"karma-coverage-istanbul-reporter": "^0.2.0",
5355
"protractor": "~5.1.0",
5456
"ts-node": "~2.0.0",
5557
"tslint": "~4.4.2",

demo/src/app/advanced/dt-instance-snippet.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ import { DataTableDirective } from 'angular-datatables';
4444
})
4545
export class DtInstanceComponent implements OnInit {
4646
@ViewChild(DataTableDirective)
47-
private datatableEl: DataTableDirective;
47+
private datatableElement: DataTableDirective;
4848
49-
dtOptions: any = {};
49+
dtOptions: DataTables.Settings = {};
5050
51-
displayToConsole(): void {
52-
this.datatableEl.dtInstance.then(dtInstance => console.log(dtInstance));
51+
displayToConsole(datatableElement: DataTableDirective): void {
52+
datatableElement.dtInstance.then((dtInstance: DataTables.Api) => console.log(dtInstance));
5353
}
5454
5555
ngOnInit(): void {

demo/src/app/advanced/dt-instance.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export class DtInstanceComponent implements OnInit {
1010
@ViewChild(DataTableDirective)
1111
private datatableElement: DataTableDirective;
1212

13-
dtOptions: any = {};
13+
dtOptions: DataTables.Settings = {};
1414

1515
displayToConsole(datatableElement: DataTableDirective): void {
16-
datatableElement.dtInstance.then(dtInstance => console.log(dtInstance));
16+
datatableElement.dtInstance.then((dtInstance: DataTables.Api) => console.log(dtInstance));
1717
}
1818

1919
ngOnInit(): void {

demo/src/app/advanced/load-dt-options-with-promise-snippet.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import 'rxjs/add/operator/toPromise';
3636
templateUrl: 'load-dt-options-with-promise.component.html'
3737
})
3838
export class LoadDtOptionsWithPromiseComponent implements OnInit {
39-
dtOptions: any = {};
39+
dtOptions: DataTables.Settings = {};
4040
4141
constructor(@Inject(Http) private http: Http) {}
4242

demo/src/app/advanced/load-dt-options-with-promise.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'rxjs/add/operator/toPromise';
88
templateUrl: 'load-dt-options-with-promise.component.html'
99
})
1010
export class LoadDtOptionsWithPromiseComponent implements OnInit {
11-
dtOptions: any = {};
11+
dtOptions: DataTables.Settings = {};
1212

1313
constructor( @Inject(Http) private http: Http) { }
1414

demo/src/app/advanced/row-click-event-snippet.component.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ export class RowClickEventSnippetComponent {
2727
<pre>
2828
<code class="typescript highlight">import { Component, NgZone, OnInit } from '@angular/core';
2929
30-
declare var $: any;
31-
3230
@Component({
3331
selector: 'row-click-event',
3432
templateUrl: 'row-click-event.component.html'
3533
})
3634
export class RowClickEventComponent implements OnInit {
37-
message: string = '';
38-
dtOptions: any = {};
35+
message = '';
36+
dtOptions: DataTables.Settings = {};
3937
4038
constructor(private zone: NgZone) { }
4139
@@ -56,15 +54,15 @@ export class RowClickEventComponent implements OnInit {
5654
title: 'Last name',
5755
data: 'lastName'
5856
}],
59-
rowCallback: (nRow: number, aData: any, iDisplayIndex: number, iDisplayIndexFull: number) => {
60-
let self = this;
57+
rowCallback: (row: Node, data: any[] | Object, index: number) => {
58+
const self = this;
6159
// Unbind first in order to avoid any duplicate handler
6260
// (see https://github.com/l-lin/angular-datatables/issues/87)
63-
$('td', nRow).unbind('click');
64-
$('td', nRow).bind('click', () => {
65-
self.someClickHandler(aData);
61+
$('td', row).unbind('click');
62+
$('td', row).bind('click', () => {
63+
self.someClickHandler(data);
6664
});
67-
return nRow;
65+
return row;
6866
}
6967
};
7068
}

demo/src/app/advanced/row-click-event.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { Component, NgZone, OnInit } from '@angular/core';
22

3-
declare var $: any;
4-
53
@Component({
64
selector: 'app-row-click-event',
75
templateUrl: 'row-click-event.component.html'
86
})
97
export class RowClickEventComponent implements OnInit {
108
message = '';
11-
dtOptions: any = {};
9+
dtOptions: DataTables.Settings = {};
1210

1311
constructor(private zone: NgZone) { }
1412

@@ -29,15 +27,15 @@ export class RowClickEventComponent implements OnInit {
2927
title: 'Last name',
3028
data: 'lastName'
3129
}],
32-
rowCallback: (nRow: number, aData: any, iDisplayIndex: number, iDisplayIndexFull: number) => {
30+
rowCallback: (row: Node, data: any[] | Object, index: number) => {
3331
const self = this;
3432
// Unbind first in order to avoid any duplicate handler
3533
// (see https://github.com/l-lin/angular-datatables/issues/87)
36-
$('td', nRow).unbind('click');
37-
$('td', nRow).bind('click', () => {
38-
self.someClickHandler(aData);
34+
$('td', row).unbind('click');
35+
$('td', row).bind('click', () => {
36+
self.someClickHandler(data);
3937
});
40-
return nRow;
38+
return row;
4139
}
4240
};
4341
}

demo/src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HttpModule } from '@angular/http';
55

66
import { HighlightJsModule, HighlightJsService } from 'angular2-highlight-js';
77

8-
import { DataTablesModule } from './angular-datatables';
8+
import { DataTablesModule } from 'angular-datatables';
99

1010
import { AppRoutingModule } from './app.routing';
1111

demo/src/app/basic/angular-way-snippet.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Person {
5454
templateUrl: 'angular-way.component.html'
5555
})
5656
export class AngularWayComponent implements OnInit {
57-
dtOptions: any = {};
57+
dtOptions: DataTables.Settings = {};
5858
persons: Person[] = [];
5959
// We use this trigger because fetching the list of persons can be quite long,
6060
// thus we ensure the data is fetched before rendering

demo/src/app/basic/angular-way.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Person {
1515
templateUrl: 'angular-way.component.html'
1616
})
1717
export class AngularWayComponent implements OnInit {
18-
dtOptions: any = {};
18+
dtOptions: DataTables.Settings = {};
1919
persons: Person[] = [];
2020
// We use this trigger because fetching the list of persons can be quite long,
2121
// thus we ensure the data is fetched before rendering
@@ -25,8 +25,7 @@ export class AngularWayComponent implements OnInit {
2525

2626
ngOnInit(): void {
2727
this.dtOptions = {
28-
paginationType: 'full_numbers',
29-
displayLength: 2
28+
pagingType: 'full_numbers'
3029
};
3130
this.http.get('data/data.json')
3231
.map(this.extractData)

demo/src/app/basic/with-ajax-snippet.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class WithAjaxSnippetComponent {
3333
templateUrl: 'with-ajax.component.html'
3434
})
3535
export class WithAjaxComponent implements OnInit {
36-
dtOptions: any = {};
36+
dtOptions: DataTables.Settings = {};
3737
3838
ngOnInit(): void {
3939
this.dtOptions = {

demo/src/app/basic/with-ajax.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Component, OnInit } from '@angular/core';
55
templateUrl: 'with-ajax.component.html'
66
})
77
export class WithAjaxComponent implements OnInit {
8-
dtOptions: any = {};
8+
dtOptions: DataTables.Settings = {};
99

1010
ngOnInit(): void {
1111
this.dtOptions = {

demo/src/app/basic/with-options-snippet.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,14 @@ export class WithOptionsSnippetComponent {
9999
templateUrl: 'with-options.component.html'
100100
})
101101
export class WithOptionsComponent implements OnInit {
102-
dtOptions: any = {};
102+
dtOptions: DataTables.Settings = {};
103103
104104
ngOnInit(): void {
105105
this.dtOptions = {
106-
displayLength: 2,
107-
paginationType: 'full_numbers'
106+
pagingType: 'full_numbers'
108107
};
109108
}
110-
}</code>
109+
}/code>
111110
</pre>
112111
`;
113112
}

demo/src/app/basic/with-options.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { Component, OnInit } from '@angular/core';
55
templateUrl: 'with-options.component.html'
66
})
77
export class WithOptionsComponent implements OnInit {
8-
dtOptions: any = {};
8+
dtOptions: DataTables.Settings = {};
99

1010
ngOnInit(): void {
1111
this.dtOptions = {
12-
displayLength: 2,
13-
paginationType: 'full_numbers'
12+
pagingType: 'full_numbers'
1413
};
1514
}
1615
}

demo/src/app/getting-started.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class GettingStartedComponent {
1010
<code class="bash highlight">npm install jquery --save
1111
npm install datatables.net --save
1212
npm install datatables.net-dt --save
13-
npm install angular-datatables --save</code>
13+
npm install angular-datatables --save
14+
npm install @types/jquery --save-dev
15+
npm install @types/datatables.net --save-dev</code>
1416
</pre>`;
1517

1618
angularCliJsonSnippet = `

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"devDependencies": {
4545
"@angular/compiler-cli": "~2.4.8",
4646
"@types/core-js": "~0.9.35",
47-
"@types/jasmine": "2.5.40",
47+
"@types/datatables.net": "~1.10.1",
48+
"@types/jasmine": "~2.5.40",
49+
"@types/jquery": "~2.0.41",
4850
"@types/node": "~6.0.46",
4951
"canonical-path": "0.0.2",
5052
"codelyzer": "~2.0.1",

src/angular-datatables.directive.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
import { Directive, ElementRef, Input, OnInit } from '@angular/core';
99
import { Subject } from 'rxjs/Rx';
10-
import 'jquery';
11-
import 'datatables.net';
12-
declare var $: any;
1310

1411
@Directive({
1512
selector: '[datatable]'
@@ -19,7 +16,7 @@ export class DataTableDirective implements OnInit {
1916
* The DataTable option you pass to configure your table.
2017
*/
2118
@Input()
22-
dtOptions: any = {};
19+
dtOptions: DataTables.Settings = {};
2320

2421
/**
2522
* This trigger is used if one wants to trigger manually the DT rendering
@@ -34,7 +31,7 @@ export class DataTableDirective implements OnInit {
3431
* It's possible to execute the [DataTables APIs](https://datatables.net/reference/api/) with
3532
* this variable.
3633
*/
37-
dtInstance: Promise<any>;
34+
dtInstance: Promise<DataTables.Api>;
3835

3936
constructor(private el: ElementRef) { }
4037

0 commit comments

Comments
 (0)