int
答案 0 :(得分:0)
纠正了一些错误。请查看此工作plunker。
var myapp=angular.module('myApp',[]) ;
myapp.controller('productController',function($scope){
$scope.listProducts=[ {id :'P01',name :'Milk',price : 40,quantity:10 }, {id :'P02',name :'Butter',price :50,quantity:11 }, {id :'P03',name :'Biscuits',price :60,quantity:12 } ,{id :'P04',name :'Chocolate',price :70,quantity:13 } ];
});
答案 1 :(得分:0)
您的应用程序中存在很多语法错误。其次,你的角度参考是错误的。请查看以下关于plunker的工作示例:
<强>的index.html 强>
<!DOCTYPE html>
<html lang="en-US" ng-app="myApp">
<head>
<meta charset="ISO-8859-1" />
<title>AngularJS_Index</title>
</head>
<body>
<script src="https://code.angularjs.org/1.4.8/angular.js"></script>
<script type="text/javascript" src="script.js"></script>
<div ng-controller="productController">
<table border="2">
<tbody>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<tr data-ng-repeat="product in listProducts">
<td>{{product.id}}</td>
<td>{{product.name}}</td>
<td>{{product.price}}</td>
<td>{{product.quantity}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<强>的script.js 强>
var myapp = angular.module('myApp', []);
myapp.controller('productController', function($scope) {
$scope.listProducts = [{
id: 'P01',
name: 'Milk',
price: 40,
quantity: 10
}, {
id: 'P02',
name: 'Butter',
price: 50,
quantity: 11
}, {
id: 'P03',
name: 'Biscuits',
price: 60,
quantity: 12
}, {
id: 'P04',
name: 'Chocolate',
price: 70,
quantity: 13
}];
});
答案 2 :(得分:0)
由,
运算符分隔每个对象。您的解决方案将完美运行:
尝试:
$scope.listProducts=[ {id :'P01',name :'Milk',price : 40,quantity:10 }, {id :'P02',name :'Butter',price :50,quantity:11 }, {id :'P03',name :'Biscuits',price :60,quantity:12 }, {id :'P04',name :'Chocolate',price :70,quantity:13 } ];
代替:
$scope.listProducts=[ {id :'P01',name :'Milk',price : 40,quantity:10 } {id :'P02',name :'Butter',price :50,quantity:11 } {id :'P03',name :'Biscuits',price :60,quantity:12 } {id :'P04',name :'Chocolate',price :70,quantity:13 } ];
输出
感谢。