<!DOCTYPE html>
<html ng-app="mo">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="js/angular.js"></script>
<!-- <script src="js/index.js"></script> -->
</head>
<body>
<div ng-controller="proCtrl">
<table class="bg">
<tr>
<th>序号</th>
<th>名称</th>
<th>图片</th>
<th>价格</th>
</tr>
<tr ng-repeat="(k,x) in productList">
<td>{{k+1}}</td>
<td>{{x.pName}}</td>
<td>
<img ng-src="imges/{{x.imgUrl}}" alt="" style="width: 60px ;height: 60px;">
</td>
<td>{{x.price}}</td>
</tr>
</table>
<button ng-click="loadMore()" class="btn">加载更多</button>
<script >
angular.module("mo",[]).
controller("proCtrl",function($scope) {
$scope.productList=[
{pName:"商品1",imgUrl:"1.jpg",price:"100"},
{pName:"商品2",imgUrl:"2.jpg",price:"500"},
{pName:"商品3",imgUrl:"3.jpg",price:"800"},
{pName:"商品3",imgUrl:"4.jpg",price:"600"}
];
$scope.loadMore=function(){
for(var i=0;i<4;i++){
var p=[];
p.pName="商品1"+parseInt(Math.random()*30);
p.imgUrl=i+1+".jpg";
p.price=parseInt(Math.random()*500+1);
$scope.productList.push(p);
}
}
})
</script>
</div>
</body>
</html>
<html ng-app="mo">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="js/angular.js"></script>
<!-- <script src="js/index.js"></script> -->
</head>
<body>
<div ng-controller="proCtrl">
<table class="bg">
<tr>
<th>序号</th>
<th>名称</th>
<th>图片</th>
<th>价格</th>
</tr>
<tr ng-repeat="(k,x) in productList">
<td>{{k+1}}</td>
<td>{{x.pName}}</td>
<td>
<img ng-src="imges/{{x.imgUrl}}" alt="" style="width: 60px ;height: 60px;">
</td>
<td>{{x.price}}</td>
</tr>
</table>
<button ng-click="loadMore()" class="btn">加载更多</button>
<script >
angular.module("mo",[]).
controller("proCtrl",function($scope) {
$scope.productList=[
{pName:"商品1",imgUrl:"1.jpg",price:"100"},
{pName:"商品2",imgUrl:"2.jpg",price:"500"},
{pName:"商品3",imgUrl:"3.jpg",price:"800"},
{pName:"商品3",imgUrl:"4.jpg",price:"600"}
];
$scope.loadMore=function(){
for(var i=0;i<4;i++){
var p=[];
p.pName="商品1"+parseInt(Math.random()*30);
p.imgUrl=i+1+".jpg";
p.price=parseInt(Math.random()*500+1);
$scope.productList.push(p);
}
}
})
</script>
</div>
</body>
</html>