您好,欢迎来到59财经网。
搜索
您的当前位置:首页怎样让Angular里的集合数据遍历显示

怎样让Angular里的集合数据遍历显示

来源:59财经网


这次给大家带来怎样让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>

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:

Swiper里自定义分页器使用步奏详解

swiper插件怎样切换箭头按钮

Copyright © 2019- win5999.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务