angular - 打印ng-table标题动态

时间:2017-05-25 22:22:50

标签: javascript angularjs ngtable

我遇到了想要使用ng-table动态打印子标题标题的点,标题应该是type1 type2 type3而Details必须是主头,子类型值必须是子标题详情请见enter image description here

下面的图片

任何帮助都会受到很大的影响。

1 个答案:

答案 0 :(得分:0)

试试这个: https://plnkr.co/edit/gypa0JDAZqhNwWcRQK93?p=preview

            <body ng-controller="MainCtrl">
              <p>Hello {{name}}!</p>
              <table ng-table="tableParams">
                <tr>
                  <td colspan="3"></td>
                  <td colspan="{{detailsCount}}" style="text-align:center">Details</td>
                </tr>
                <tr ng-repeat="i in dataObject">
                  <td title="'Type1'">{{i.type1}}</td>
                  <td title="'Type2'">{{i.type2}}</td>
                  <td title="'Type3'">{{i.type3}}</td>
                  <td ng-repeat="d in i.details" ng-init="detailsColCount(i.details)">{{d.subTypeCode}}</td>
                </tr>
              </table>
            </body>

            $scope.detailsCount = 0;
            $scope.detailsColCount = function(details){
                  if (details.length > $scope.detailsCount) {
                    $scope.detailsCount = details.length;
                  }
                };