使用angular实现购物车列表

本文介绍了一个使用Angular开发的购物车应用程序实例。该应用包括输入框用于快速搜索商品,表格显示了购物车中商品的各项信息,如产品编号、名称、数量等,并提供了增加、减少和删除商品的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看路径https://eight1302.github.io/angular/index.html

<body ng-app>



<div style="margin-left:auto; margin-right:auto; width:600px; padding-top:30px">
    <input  type="text" name="" value=""  ng-model="abc" placeholder="输入关键字快速查找">{{abc}}
    </div>

<div ng-controller="cartController" class="container">
<table class="table" ng-show="cart.length">
<thead>
<tr>
<th>产品编号</th>
<th>产品名字</th>
<th>购买数量</th>
<th>产品单价</th>
<th>产品总价</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in cart| filter:abc">
<td ng-bind="item.id"></td>
<td ng-bind="item.name"></td>
<td>
<button type="button" ng-click="reduce(item.id)" class="btn btn-primary btn-sm">-</button>
<input type="text" ng-model="item.quantity" style="text-align: center;">
<button type="button" ng-click="add(item.id)" class="btn btn-primary btn-sm">+</button>
</td>
<td ng-bind="item.price"></td>
<td ng-bind="item.price*item.quantity"></td>
<td><button type="button" ng-click="remove(item.id)" class="btn btn-danger btn-sm">移除</button></td>
</tr>
<tr>
<td>总购物价</td>
<td ng-bind="totalPrice()"></td>
<td>总购买数量</td>
<td ng-bind="totalQuantity()"></td>
<td colspan="2"><button type="button"  ng-click="cart = {}" class="btn btn-danger btn-sm">清空购物车</button></td>
</tr>
</tbody>
</table>
<p ng-show="!cart.length">您的购物车已空</p>

</div>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值