AngularJS 实现购物车全选反选功能
(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )
废话不多说了,直接给大家贴代码了,具体代码如下所示;
<!DOCTYPE html> <html lang="en" ng-app="testMo"> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="css/bootstrap.css" rel="external nofollow" > <style> .div1{ margin: 20px; } </style> </head> <body> <div ng-controller="testCtrl" class="div1"> <h4>angularJS--购物车实现全选/取消全选</h4> <button type="button" class="btn btn-info" ng-click="addProduct()">添加商品</button> <button type="button" class="btn btn-danger" ng-click="deleteProduct()">删除商品</button> <br><br> <table class="table table-bordered table-responsive" > <thead> <td>操作</td> <td>check状态</td> <td>商品名称</td> <td>单价</td> <td>数量</td> <td>小计</td> </thead> <tr ng-repeat="p in cart" > <td><input type="checkbox" ng-checked="p.checked" ng-click="echoChange(p.id,p.checked,selectAll)"></td> <td>{{p.checked}}||{{p.checked}}</td> <td>{{p.name}}</td> <td>单价:¥{{p.price}}</td> <td>数量:<input type="number" ng-model="p.count" min="0" value="p.count"></td> <td>小计:¥{{p.sum}}</td> </tr> </table> <br> <input type="checkbox" ng-model="selectAll" ng-click="selectAllClick(selectAll)"><span ng-hide="selectAll" >全选</span><span ng-show="selectAll">取消全选</span> <br><br> 已选择<span>{{jishuqi}}</span>件商品,总金额:<span>¥{{ sumTotal }}</span> </div> <script src="/UploadFiles/2021-04-02/angular.js">PS:下面给大家分享angularjs 购物车的代码,具体代码如下所示:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>购物车</title> <script type="text/javascript" src="/UploadFiles/2021-04-02/angular.js">好了,代码到此结束。
总结
以上所述是小编给大家介绍的AngularJS 实现购物车全选反选功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
下一篇:React Native时间转换格式工具类分享