最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AngularJS表格添加序號的方法

 更新時間:2017年03月03日 10:17:42   作者:翱翔天地  
這篇文章主要介紹了AngularJS表格添加序號的方法,涉及AngularJS表格的遍歷及序號添加實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了AngularJS表格添加序號的方法。分享給大家供大家參考,具體如下:

1、問題背景

AngularJS表格需要序號,可以利用$index來作為序號

2、實(shí)現(xiàn)實(shí)例

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>AngularJS之表格序號</title>
    <link rel="stylesheet" href="css/bootstrap.css" rel="external nofollow" />
    <script src="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:"升力",age:"22"},
          {no:"2016010108",name:"劉華",age:"24"},
          {no:"2016010109",name:"京兆",age:"20"},
          {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>學(xué)號</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、實(shí)現(xiàn)結(jié)果

更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)

希望本文所述對大家AngularJS程序設(shè)計有所幫助。

相關(guān)文章

最新評論

义马市| 万载县| 宜君县| 横山县| 襄城县| 泽州县| 卢龙县| 九江市| 宁远县| 日喀则市| 安庆市| 茌平县| 登封市| 揭西县| 西昌市| 安福县| 霞浦县| 二连浩特市| 浦北县| 龙海市| 鄂尔多斯市| 承德县| 定安县| 阿鲁科尔沁旗| 安仁县| 江川县| 浠水县| 龙岩市| 潞西市| 清丰县| 沧州市| 凤庆县| 扎赉特旗| 梁平县| 正宁县| 金平| 定远县| 康马县| 凤城市| 茂名市| 墨脱县|