Angular4 添加了第二个 tbody 元素。

3

我希望在几个表格中展示一些数据。但是Angular 4会添加许多新的div和一个破坏我的表格的新tbody。

以下是模板:

<div *ngFor= "let table of qmc.simplificationTable; let myIndex = index">

    <table class="table table-bordered col-md-4">
      <thead>
        <tr>
          <th>Group</th>
          <th>Vars</th>
          <th>Benutzt</th>
        </tr>
      </thead>

      <tbody>
        <div *ngFor= "let group of table let groupIndex = index">
          <div *ngFor= "let primeImplicant of group">
            <tr>
              <td>
                {{groupIndex}}
              </td>
              <td>
                {{primeImplicant.toString()}}
              </td>
              <td>
                {{primeImplicant._usedForCombination}}
              </td>
            </tr>
          </div>
        </div>
      </tbody>

    </table>

  </div>

这是HTML的结果: https://pastebin.com/z5UneyMf 可以看到Angular4在每个表格中添加了一个新的tbody元素。
<tr>

这些tbodies和新的divs破坏了我的表格。
我该如何解决这个问题?

你能为同样的内容添加一个 Plunker 吗? - Rahul Singh
1
你试过使用<ng-container *ngFor代替<div *ngFor吗? - yurzui
那很好!谢谢。 - leet
1个回答

0

只需将

<div *ngFor

替换为

<ng-container *ngFor

感谢yurzui(在评论中提出的想法)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接