Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Shopping cart by AngularJs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how AngularJs implements a shopping cart. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Code:

Shopping cart .box {width: 100%; border-bottom: 1px solid silver;} .box1 {width: 100%; margin-top: 5px;} .box1 button {width: 100px; height: 40px; background: crimson; color: white; text-align: center; line-height: 40px; float: right; border: 0; border-radius: 13px } table {width: 100%;} tr td button {background: blue; color: white; border: 0;} var my=angular.module ("my", []) My.controller ("mys", function ($scope) {/ * declare data objects and initialize commodity information Data self-designed and not less than four * / $scope.arr= [{name: "qq", price:12.9,number:2,state:false}, {name: "wx", price:23.9,number:1,state:false}, {name: "aa", price:99.9,number:1,state:false}, {name: "bb", price:10.9,number:5,state:false}] / * delete entry * / $scope.del=function (index) {if (confirm ("are you sure you want to remove this item?")) {$scope.arr.splice (index,1);}} / * Click the "+" button to add 1 to the quantity in the input box, and you can calculate the subtotal price of the goods and the total price of the shopping car * / $scope.jia=function (index) {$scope.arr [index] .number + +. } / * when the "-" button is clicked, the quantity in the input box is minus 1, and the total price of the commodity is * / $scope.jian=function (index) {if ($scope.arr [index] .number > 1) {$scope.arr [index] .number-- } else if ($scope.arr [index] .number = = 1) {if (confirm ("whether the user deletes the product") {$scope.arr.splice (index,1);} / * calculate the total price * / $scope.allSum=function () {var allPrice=0; for (var itemo / I)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report