zoukankan      html  css  js  c++  java
  • AngularJS实现三级Table列表

    angular.module('yo03App')
      .controller('MyrouteCtrl', function ($scope) {
        $scope.professors = [{
        'name': 'Albert Einstein', 'count':'5',
        'classes': [{
            'name': 'Physics 101',
            'students': [{
                'name': 'Joe',
                'grade': 'B'
            }, {
                'name': 'Mary',
                'grade': 'A'
            }]
        }, {
            'name': 'Physics 201',
            'students': [{
                'name': 'Gunther',
                'grade': 'C'
            }, {
                'name': 'Hans',
                'grade': 'C'
            }, {
                'name': '哈哈哈',
                'grade': 'B'
            }]
        }]
    }, {
        'name': 'Charles Darwin', 'count':'4',
        'classes': [{
            'name': 'Biololgy 101',
            'students': [{
                'name': 'Danielle',
                'grade': 'A'
            }, {
                'name': 'Anne',
                'grade': 'A'
            }]
        }, {
            'name': 'Biology 201',
            'students': [{
                'name': 'Frida',
                'grade': 'A'
            }, {
                'name': 'Fritz',
                'grade': 'F'
            }]
        }]
    }];
      });

    注意:count可以通过后台计算组装,前台也可以通过JS计算。

    <table>
        <tbody>
            <tr ng-repeat-start="p in professors" ng-if="false"></tr>
            <tr ng-repeat-start="c in p.classes" ng-if="false"></tr>
            <tr ng-repeat="s in c.students">
                <th ng-if="$parent.$first && $first" rowspan="{{p.count}}">
                    {{p.name}}
                </th>
                <th ng-if="$first" rowspan="{{c.students.length}}">{{c.name}}</th>
                <td>{{s.name}}</td>
                <td>{{s.grade}}</td>
            </tr>
            <tr ng-repeat-end ng-if="false"></tr> <!-- classes -->
            <tr ng-repeat-end ng-if="false"></tr> <!-- professors -->
        </tbody>
    </table>
  • 相关阅读:
    PS插件安装
    在linux中安装Python
    快慢指针 | 环形链表
    Intel VT-x 支持但处于禁用状态开启
    函数
    连接(交叉连接、内连接、外连接、自连接)
    游标cursor 与循环fetch
    Identity 自增长标识
    Trigger 触发器
    Procedure 存储过程
  • 原文地址:https://www.cnblogs.com/yshyee/p/9271689.html
Copyright © 2011-2022 走看看