zoukankan      html  css  js  c++  java
  • 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

    如上所示!

  • 相关阅读:
    Grakn Forces 2020 I. Bitwise Magic
    October Challenge 2020 Division 1
    杂题
    杂题
    杂题
    hdu 6868
    Codeforces Round #673 (Div. 1)
    杂题
    2019 ICPC World Finals K
    【CSP2019】括号树 题解(递推+链表)
  • 原文地址:https://www.cnblogs.com/xizhilang/p/6472901.html
Copyright © 2011-2022 走看看