AngularJS集合数据遍历显示

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a772304419/article/details/78905386

AngularJS集合数据遍历显示

<!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>
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页