angular 数据二次遍历的问题

<!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>  

 

 

引自:http://blog.csdn.net/chadcao/article/details/41148833

 

如上所示!

posted @ 2017-02-27 11:24  果冻喜之郎  阅读(613)  评论(0编辑  收藏  举报