标签:var app asc 模块 cti 姓名 rip div repeat
1.循环数组
1 <script type="text/javascript"> 2 //定义一个叫myApp的模块 3 var app = angular.module(‘myApp‘,[]); 4 //定义控制器 5 app.controller(‘myController‘,function($scope){ 6 $scope.list=[100,101,102,103,104]//定义数组 7 8 }) 9 10 </script> 11 12 <body ng-app="myApp" ng-controller="myController"> 13 <table > 14 <tr ng-repeat="c in list"> 15 16 <td>{{c}}</td> 17 18 </tr> 19 </table> 20 </body>
2.循环对象数组
<script type="text/javascript"> //定义模块 var app = angular.module("myModu",[]); //定义控制器 app.controller("contrl3",function($scope){ //定义对象数组 $scope.list=[ {name:‘习大大‘,power:99,money:98}, {name:‘特朗普‘,power:100,money:99}, {name:‘普京‘,power:100,money:96}, {name:‘金三胖‘,power:70,money:50} ]; }) </script> <body ng-app="myModu" ng-controller="contrl3"> <table > <tr> <td>姓名</td> <td>权力</td> <td>金钱</td> </tr> <tr ng-repeat="pe in list"> <td>{{pe.name}}</td> <td>{{pe.power}}</td> <td>{{pe.money}}</td> </tr> </table> </body>
标签:var app asc 模块 cti 姓名 rip div repeat
原文地址:https://www.cnblogs.com/Mr-Brown/p/9621584.html