【问题标题】:why "<ng-container> not working in "<tr>" tag为什么“<ng-container> 在“<tr>”标签中不起作用
【发布时间】:2017-05-04 05:24:28
【问题描述】:

代码:

<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>

输出:

xyz

这里的预期输出是没有显示任何单元格,但在 &lt;tr&gt;&lt;td&gt; 之间的标签 &lt;ng-container ng-if="false"&gt; 不起作用。

如果有人知道这个问题,请得到解决方案。

【问题讨论】:

    标签: angularjs angularjs-directive angular-ng-if


    【解决方案1】:

    我深入分析了这个问题,我遇到了一些情况,比如 &lt;ng-container ng-if=""&gt;&lt;ng-container ng-show=""&gt;&lt;ng-container ng-hide=""&gt; 条件在 &lt;table&gt;&lt;td&gt; 标记之间不起作用,但在 &lt;td&gt; 标记内也起作用 &lt;ng-container ng-repeat=""&gt; 在上述所有标准中都可以正常工作。

    【讨论】:

      【解决方案2】:

      尝试将 ng-container 放在表格行之前

      <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>
      

      【讨论】:

        猜你喜欢
        • 2021-11-17
        • 1970-01-01
        • 1970-01-01
        • 2021-09-06
        • 1970-01-01
        • 1970-01-01
        • 2018-03-22
        • 2018-05-05
        • 1970-01-01
        相关资源
        最近更新 更多