动态 html table 使用 Angular

Dynamic html table using Angular

我正在尝试使用 Angular.

创建动态 html table

示波器有一个二维数组(称为数组),其中包含用于生成 table 的数据。

翡翠:

table(class="table table-striped")
    thead
      tr
        th
          | Header
    tbody
      div(ng-controller="indexCtrl")
        tr(ng-repeat="row in array")
          td(class="row")
            div(ng-repeat="cell in row", class="col-md-6")
              .checkbox
                label
                  input(type="checkbox",name="{{cell.permission}}")
                    | {{cell.name}}

我想要的结果是:

x 盒子 1 x 盒子 2

x box3 x box4

目前只生成table个头像。没有行。我的模板有什么问题?

table must have there own element like td, tr, th, tbody, etc. If you want to place other element in table, you could have it in td /th only

您应该将 ng-controller 放在 tbody 元素上。

table 不允许其中的其他元素,就像您在 tbody

中放置 div
table(class="table table-striped")
    thead
      tr
        th
          | Header
    tbody(ng-controller="indexCtrl")
        tr(ng-repeat="row in array")
          td(class="row")
            div(ng-repeat="cell in row", class="col-md-6")
              .checkbox
                label
                  input(type="checkbox",name="{{cell.permission}}")
                    | {{cell.name}}