angularjs遍历两次

@{
    Layout = null;
}
<!DOCTYPE html>
<html ng-app="my_app">
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module("my_app", []);
        app.controller('my_controller', function ($scope) {
            var vm = $scope.vm = {};
            vm.classes = [
                {
                    classID: 1, className: '一班',
                    students: [
                        { studentID: 1, studentName: '张三' },
                        { studentID: 2, studentName: '李四' }
                    ]
                },
                {
                    classID: 2, className: '二班',
                    students: [
                        { studentID: 3, studentName: '王五' },
                        { studentID: 4, studentName: '马六' }
                    ]
                },
                {
                    classID: 3, className: '三班',
                    students: [
                        { studentID: 5, studentName: '曹七' },
                        { studentID: 6, studentName: '余八' }
                    ]
                },
                { classID: 4, className: '四班' }
            ];
        });
    </script>
</head>
<body ng-controller="my_controller">
    <table>
        <tr ng-repeat="class in vm.classes">
            <td>{{class.classID}}</td>
            <td>{{class.className}}</td>
            <td>
                <table>
                    <tr ng-repeat="student in class.students">
                        <td>{{student.studentID}}</td>
                        <td>{{student.studentName}}</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>  
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值