angular.js - ng-repeat 遍历 directive不生效
PHPz
PHPz 2017-05-15 17:05:53
0
1
621

Demo:http://codepen.io/mafeifan/pe...

ng-repeat 嵌套,先遍历tr再遍历td。
使用原生html能输出正确内容。
但当把td写为directive就不显示了。不知道什么原因,求指教。

PHPz
PHPz

学习是最好的投资!

reply all(1)
小葫芦

Just add variables in the controller:

    vm.list = [1,2];

table2 is modified to:

    <form-cell ng-repeat='cell in vm.list'>data</form-cell>

It can be achieved~

ng-repeat is generally not recommended to be dynamic, as this will affect performance.

If you insist on writing like this, you can write it as:

      <tr ng-repeat="grid in vm.repeatCount() track by $index">
        <td ng-repeat='cell in vm.getDataByIndex($index)'>
          <form-cell></form-cell>
        </td>
      </tr>

The value can also come:

template: '<span>data</span>',
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template