daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 519 forks source link

Additional TR or TBODY in table throws an error with MIN version of library #188

Open BobDankert opened 8 years ago

BobDankert commented 8 years ago

I was trying to add a row or tbody that would be displayed if the table is currently empty, indicating that there are no records. However, if I add a TR or TBODY that doesn't contain the ng-repeat of the element, I get an error thrown:

TypeError: Cannot read property 'replace' of undefined at Object.directiveNormalize as $normalize at Object.a as compile at applyDirectivesToNode (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:8069:32) at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:7598:15) at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:7610:15) at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:7610:15) at compile (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:7505:15) at link (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:24384:9) at invokeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:8789:9) at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js:8289:11)

As I was working on debugging this more, I found that this only happens with the MIN version of the library. When I changed this to use the non-minified library, I did not have any errors and it worked as expected.

I installed the library today using bower, if that matters. I don't see a version number in the code to confirm that the minified and non-minified files are the same version.

mnzaki commented 8 years ago

+1 We hit this as well. It breaks randomly, for us the checkboxes (and all selection functionalities) were broken. Also installed using bower today.

wmichaelfeltman commented 8 years ago

Pardon me for jumping in, but my question is why? Why not just a div after the table that you use ng-if on to display that the table is empty? That just seems much cleaner than trying to kludge a row with a message in it to me.

BobDankert commented 8 years ago

@f1tech There are many ways to handle this, an extra TR, a separate TBODY, or an element outside the table. All seem valid to me, and I ended up putting this in a TFOOT. Semantically, the content of this is related to the table and my first thought was to include it in the table. Regardless, it seems like something that should work rather than throwing the error (and does work with the non-min version of the library).