fixed-table-header icon indicating copy to clipboard operation
fixed-table-header copied to clipboard

Headings disappear if using ng-if on ancestor element

Open johnrix opened this issue 8 years ago • 6 comments

The following causes the headings to become invisible:

<div ng-if="1">
    <div style="overflow: auto; max-height: 300px;">
	<table>
		<thead fix-head>
			<tr><th>Name</th></tr>
		</thead>
		<tbody>
			<tr><td>A</td></tr>
			<tr><td>A</td></tr>
		</tbody>
  	</table>
    </div>
</div>

Removing the ng-if restores them.

johnrix avatar Apr 26 '17 21:04 johnrix

As a short term workaround you can use ng-show instead.

skortchmark9 avatar Apr 26 '17 22:04 skortchmark9

Yep, I did confirm that works at least. For some reason though, the column headings were not aligning for me, so I since gave up on using the directive. I suspect it may have been to do with me using ng-repeat on the <th> elements (I have a variable set of columns, according to a selected report).

johnrix avatar Apr 26 '17 23:04 johnrix

I don't think so, it's because the elements are all hidden when the math is done to determine their widths. As a second workaround you can do

$timeout(function() {
  // force table header to recalculate its width.
  window.dispatchEvent(new Event('resize'));
});

skortchmark9 avatar Apr 27 '17 20:04 skortchmark9

Ah good point, you're more than likely right there!

johnrix avatar Apr 27 '17 21:04 johnrix

use ng-show instead

Sayaren avatar Jan 10 '18 11:01 Sayaren

in the ng-repeat directive, the same.

ceiger89 avatar May 16 '18 07:05 ceiger89