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

Commit 5a874e4

Browse files
committed
fix: table empty check must check HTML nodes count
1 parent 1b4b25d commit 5a874e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/angular-datatables.directive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ export class DataTableDirective implements OnDestroy, OnInit {
7171
this.dtInstance = new Promise((resolve, reject) => {
7272
Promise.resolve(this.dtOptions).then(dtOptions => {
7373
// validate object
74-
if (Object.keys(dtOptions).length == 0) {
75-
reject('dtOptions cannot be empty');
74+
const isTableEmpty = Object.keys(dtOptions).length == 0 && $('tbody tr', this.el.nativeElement).length == 0;
75+
if (isTableEmpty) {
76+
reject('Both the table and dtOptions cannot be empty');
7677
return;
7778
}
7879
// Using setTimeout as a "hack" to be "part" of NgZone

0 commit comments

Comments
 (0)