问题
Code:
<table>
<tr>
<ng-container ng-if="false"> // here ng-container not working
<td>
<ng-container ng-if="false">abc</ng-container>// here ng-container working fine
</td>
<td><ng-container ng-if="true">xyz</ng-container></td>
</ng-container>
</tr>
</table>
OutPut:
xyz
here expected output is no one cell was display but in between
<tr>and<td>tags<ng-container ng-if="false">are not working.
If anyone idea about this problem please get solution.
回答1:
I analysis this issue in deep and i faced some situation like
<ng-container ng-if=""> or <ng-container ng-show=""> or <ng-container ng-hide=""> conditions not working between <table> and <td> tag but working inside <td> tag also <ng-container ng-repeat=""> is working fine in above all criteria.
回答2:
Try to put ng-container before table row
<table>
<ng-container ng-if="false">
<tr>
<td>
<ng-container ng-if="false">abc</ng-container>// here ng-container working fine
</td>
<td>
<ng-container ng-if="true">xyz</ng-container>
</td>
</tr>
</ng-container>
</table>
来源:https://stackoverflow.com/questions/43774482/why-ng-container-not-working-in-tr-tag