esvit / ng-table

Simple table with sorting and filtering on AngularJS
http://esvit.github.io/ng-table
BSD 3-Clause "New" or "Revised" License
2.77k stars 851 forks source link

Problems with ng-repeated Table and ng-if in thead #933

Open VilNeo opened 7 years ago

VilNeo commented 7 years ago

Hello,

I have written an own directive, which contains a ng-table. When following 3 situations come together, i get the error:

"TypeError: Cannot read property 'childNodes' of undefined"

  1. repeat the directive with ng-repeat
  2. place a \<thead> into the table
  3. put a \<th> into \<thead> with a ng-if or ng-show

Is this a bug or did I something wrong?

Here is a minified sample code:

HTML:

<div ng-app="myApp">
  <div data-ng-repeat="x in ['a','b']" >
    <ng-table-test>I should change</ng-table-test>
  </div>
</div>

Javascript:

angular.module('ui.directives', []).directive('ngTableTest', [ 'ngTableParams', 
    function(ngTableParams) {
      return {
          template: '<table ng-table="tableParams"><thead><tr><th data-ng-if="true">Hu</th></tr></thead></table>',
        restrict: 'E',
        scope: {},
        "link": function (scope, element, attrs) {
            var data = [{name: "Moroni", age: 50} /*,*/];
            scope.tableParams = new ngTableParams({}, { dataset: data});
        }
      };
    }]
  );
angular.module('myApp', ['ui.directives',"ngTable"]);