var myAppModule = angular.module('myApp', {});
myAppModule.controller('CartController', function($scope){
$scope.items = [
{title: 'Paints pots', quantity: 8, price: 3.95},
{title: 'Polks dots', quantity: 17, price: 12.95},
{title: 'Pebbles', quantity: 5, price: 6.95},
];
$scope.remove = function(index){
$scope.items.splice(index, 1);
}
});
<body ng-app="myApp">
<div ng-controller="CartController">
<h1>Your Shopping Cart</h1>
<div ng-repeat='item in items' class="item">
<span class="title">{{ item.title }}</span>
<input ng-model="item.quantity"/>
<span>单价:{{ item.price | currency }}</span>
<span>总价:{{ item.price * item.quantity }}</span>
<button ng-click="remove($index)">Remove</button>
</div>
</div>
</body>
h1{
text-align:center;
}
.item {
border-bottom: 1px solid #ddd;
padding:10px
}