AngularJS之表格序号
发布时间:2020-12-17 09:49:44 所属栏目:安全 来源:网络整理
导读:1、问题背景 AngularJS表格需要序号,可以利用$index来作为序号 2、实现实例 !DOCTYPE htmlhtmlheadmeta charset="UTF-8"titleAngularJS之表格序号/titlelink rel="stylesheet" href="../css/bootstrap.css" /script src="http://cdn.static.runoob.com/libs
1、问题背景 AngularJS表格需要序号,可以利用$index来作为序号 2、实现实例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AngularJS之表格序号</title> <link rel="stylesheet" href="../css/bootstrap.css" /> <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> <style> table,th,td{ border-collapse: collapse; } table tr:nth-child(even){ background-color: #F7E1B5; } table tr:nth-child(odd){ background-color: #F1F1F1; } </style> <script> var app = angular.module("tableStyleApp",[]); app.controller("tableStyleController",function($scope){ $scope.datas = [ {no:"2016010101",name:"张思",age:"23"},{no:"2016010102",name:"赵虎",age:"22"},{no:"2016010103",name:"李磊",age:"24"},{no:"2016010104",name:"孙雪",age:"21"},{no:"2016010105",name:"郝蕾",age:"20"},{no:"2016010106",name:"朱峰",age:"25"},{no:"2016010107",name:"升力",{no:"2016010108",name:"刘华",{no:"2016010109",name:"京兆",{no:"2016010110",name:"张峰",age:"22"} ] }); </script> </head> <body> <div ng-app="tableStyleApp" ng-controller="tableStyleController"> <table class="table table-bordered table-condensed"> <thead> <tr> <th>序号</th> <th>学号</th> <th>姓名</th> <th>年龄</th> </tr> </thead> <tbody> <tr ng-repeat="data in datas"> <td>{{$index+1}}</td> <td>{{data.no}}</td> <td>{{data.name}}</td> <td>{{data.age}}</td> </tr> </tbody> </table> </div> </body> </html> 3、实现结果 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读