<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/angular-route.js"></script>
<script type="text/javascript" src="js/ionic.bundle.min.js"></script>
<script>
var app = angular.module("myapp", []);
app.controller("myCtrl", function($scope) {
$scope.ss=false;
$scope.users = [{
id: 1,
checked: false,
name: "皮鞋",
price: 18,
numbers: 56
}, {
id: 2,
checked: false,
name: "短裤",
price: 20,
numbers: 58
}, {
id: 3,
checked: false,
name: "西裤",
price: 12,
numbers: 60
}, {
id: 4,
checked: false,
name: "西瓜",
price: 22,
numbers: 50
}];
$scope.j = function() {
}
$scope.pl = function(unm) {
var arr = [];
for (index in $scope.users) {
if ($scope.users[index].checked==true) {
arr.push($scope.users[index]);
}
}
for (index1 in arr) {
for(index2 in $scope.users){
if(arr[index1]==$scope.users[index2]){
$scope.users.splice(index2,1);
}
}
}
}
$scope.san = function(uun){
for(indexx in $scope.users){
if($scope.users[indexx].id==uun){
$scope.users.splice(indexx,1);
}
}
}
$scope.bd = function (){
$scope.cc=0;
for(index1 in $scope.users){
$scope.cc=$scope.cc+($scope.users[index1].price)*($scope.users[index1].numbers);
}
return $scope.cc;
}
$scope.cf = function (aa){
for(index3 in $scope.users){
if($scope.users[index3].id==aa){
$scope.users[index3].price-1;
}
}
return sz;
}
})
</script>
<style>
.d{width: 50px;}
</style>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<center><button ng-click="yc=true">添加</button><button ng-click="pl()">批量删除</button></center>
<center>
<table border="1" width="700">
<thead>
<tr>
<td><input type="checkbox"></td>
<td>ID</td>
<td>名称商品</td>
<td>价格</td>
<td>数量</td>
<td>小计</td>
<td>操作</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td><input type="checkbox" ng-model="user.checked"></td>
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td></span><button ng-click="user.price=user.price-1">-</button><input type="text" value="{{user.price}}" class="d"><button ng-click="user.price=user.price+1">+</button></td>
<td>{{user.numbers}}</td>
<td>{{user.numbers*user.price | currency:"¥"}}</td>
<td><button ng-click="san(user.id)">删除</button></td>
</tr>
<tr><td ng-bind="bd()">总价:{{cc}}</td></tr>
</tbody>
</table>
</center>
</body>
</html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/angular-route.js"></script>
<script type="text/javascript" src="js/ionic.bundle.min.js"></script>
<script>
var app = angular.module("myapp", []);
app.controller("myCtrl", function($scope) {
$scope.ss=false;
$scope.users = [{
id: 1,
checked: false,
name: "皮鞋",
price: 18,
numbers: 56
}, {
id: 2,
checked: false,
name: "短裤",
price: 20,
numbers: 58
}, {
id: 3,
checked: false,
name: "西裤",
price: 12,
numbers: 60
}, {
id: 4,
checked: false,
name: "西瓜",
price: 22,
numbers: 50
}];
$scope.j = function() {
}
$scope.pl = function(unm) {
var arr = [];
for (index in $scope.users) {
if ($scope.users[index].checked==true) {
arr.push($scope.users[index]);
}
}
for (index1 in arr) {
for(index2 in $scope.users){
if(arr[index1]==$scope.users[index2]){
$scope.users.splice(index2,1);
}
}
}
}
$scope.san = function(uun){
for(indexx in $scope.users){
if($scope.users[indexx].id==uun){
$scope.users.splice(indexx,1);
}
}
}
$scope.bd = function (){
$scope.cc=0;
for(index1 in $scope.users){
$scope.cc=$scope.cc+($scope.users[index1].price)*($scope.users[index1].numbers);
}
return $scope.cc;
}
$scope.cf = function (aa){
for(index3 in $scope.users){
if($scope.users[index3].id==aa){
$scope.users[index3].price-1;
}
}
return sz;
}
})
</script>
<style>
.d{width: 50px;}
</style>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<center><button ng-click="yc=true">添加</button><button ng-click="pl()">批量删除</button></center>
<center>
<table border="1" width="700">
<thead>
<tr>
<td><input type="checkbox"></td>
<td>ID</td>
<td>名称商品</td>
<td>价格</td>
<td>数量</td>
<td>小计</td>
<td>操作</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td><input type="checkbox" ng-model="user.checked"></td>
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td></span><button ng-click="user.price=user.price-1">-</button><input type="text" value="{{user.price}}" class="d"><button ng-click="user.price=user.price+1">+</button></td>
<td>{{user.numbers}}</td>
<td>{{user.numbers*user.price | currency:"¥"}}</td>
<td><button ng-click="san(user.id)">删除</button></td>
</tr>
<tr><td ng-bind="bd()">总价:{{cc}}</td></tr>
</tbody>
</table>
</center>
</body>
</html>