首頁  >  文章  >  web前端  >  怎樣讓Angular裡的集合資料遍歷顯示

怎樣讓Angular裡的集合資料遍歷顯示

php中世界最好的语言
php中世界最好的语言原創
2018-04-13 14:06:342380瀏覽

這次帶給大家怎樣讓Angular裡的集合資料遍歷顯示,讓Angular裡集合資料遍歷顯示的注意事項有哪些,下面就是實戰案例,一起來看一下。

如下:

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>AngularJS集合数据遍历显示</title>
  <script type="text/javascript" src="../js/angular.min.js"></script>
 </head>
 <body ng-app="myapp" ng-controller="myctrl">
  <table width="100%" border="1">
   <tr>
    <td>序号</td>
    <td>商品编号</td>
    <td>商品名称</td>
    <td>价格</td>
   </tr>
   <tr ng-repeat="product in products">
    <td>{{$index+1}}</td>
    <td>{{product.id}}</td>
    <td>{{product.name}}</td>
    <td>{{product.price}}</td>
   </tr>
  </table>
 </body>
 <script type="text/javascript">
  var myapp = angular.module("myapp",[]);
  myapp.controller("myctrl",["$scope",function($scope){
   $scope.products = [
    {
     id:1001,
     name:'数码相机',
     price:5000
    },
    {
     id:1002,
     name:'华为手机',
     price:4000
    }
   ];
  }])
 </script>
</html>

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

Swiper裡自訂分頁器使用步奏詳解

swiper外掛程式怎麼切換箭頭按鈕

以上是怎樣讓Angular裡的集合資料遍歷顯示的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn