我正在构建一个购物应用程序。在应用程序的某个地方,我需要显示用户的购物车并让他编辑它。我有删除按钮但不工作...
<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head>
<title>Your Shopping Cart</title>
</head>
<body ng-controller="CartController">
<h1>Your Order</h1>
<div ng-repeat="item in items">
<span>{{item.title}}</span>
<input ng-model="item.quantity" />
<span>{{item.price | currency}}</span>
<span>{{item.price * item.quantity | currency}}</span>
<button ng-click="remove($index)">Remove</button>
</div>
<script src="js/angular.min.js"></script>
<script>
function CartController($scope) {
$scope.items = [
{title:'Srimad Bhagwat', quantity:8, price:3.95},
{title:'rupa chintamani', quantity:17, price:12.95},
{title:'ram charit manas', quantity:5, price:6.95}
];
};
$scope.remove = function (index) {
$scope.items.splice(index, 1);
}
</script>