AngularJS实现购物车模糊查询,价格区间查找,根据名字删除,点击排序
2017-11-17 20:10
726 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>购物车</title>
<script type="text/javascript" src="angular/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$rootScope){
$scope.list = [{
id:80,
name:"iphone",
price:5400
},{
id:1200,
name:"ipad mini",
price:2200
},{
id:500,
name:"ipad air",
price:2340
},{
id:29,
name:"ipad",
price:1420
}];
$scope.del=function(name){
/*$scope.list.splice(index,1);*/
for(index in $scope.list){
if($scope.list[index].name==name){
$scope.list.splice(index,1);
}
}
};
$scope.show = function(){
if($scope.list.length>0){
return true;
}else{
return false;
}
};
//价格区间的功能
$scope.ss="请选择";
$scope.money=function (item) {
var arr=$scope.ss.split("-");
var min=arr[0];
var max=arr[1];
if(item<min||item>max){
return false;
}else{
return true;
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl" align="center">
<input type="text" placeholder="产品名称" ng-model="query" />
产品价格:<select ng-model="ss">
<option>请选择</option>
<option selected="selected">1000-2000</option>
<option>2000-3000</option>
<option>3000-4000</option></select><br />
<table ng-show="show()" style="margin-top: 50px;" align="center" cellpadding="5" cellspacing="0" border="1px solid #000">
<thead>
<tr>
<th ng-click="desc=!desc;col='id'">产品编号</th>
<th ng-click="desc=!desc;col='name'">产品名称</th>
<th ng-click="desc=!desc;col='price'">产品价格</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="l in list | filter:{'name':query} | orderBy:col:desc; " ng-if="money(l.price)">
<td>{{l.id}}</td>
<td>{{l.name}}</td>
<td>{{l.price | currency:"(RMB)"}}</td>
<td><button ng-click="del(l.name)">删除</button></td>
</tr>
</tbody>
</table>
<p ng-if="!show()">购物车为空</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8" />
<title>购物车</title>
<script type="text/javascript" src="angular/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$rootScope){
$scope.list = [{
id:80,
name:"iphone",
price:5400
},{
id:1200,
name:"ipad mini",
price:2200
},{
id:500,
name:"ipad air",
price:2340
},{
id:29,
name:"ipad",
price:1420
}];
$scope.del=function(name){
/*$scope.list.splice(index,1);*/
for(index in $scope.list){
if($scope.list[index].name==name){
$scope.list.splice(index,1);
}
}
};
$scope.show = function(){
if($scope.list.length>0){
return true;
}else{
return false;
}
};
//价格区间的功能
$scope.ss="请选择";
$scope.money=function (item) {
var arr=$scope.ss.split("-");
var min=arr[0];
var max=arr[1];
if(item<min||item>max){
return false;
}else{
return true;
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl" align="center">
<input type="text" placeholder="产品名称" ng-model="query" />
产品价格:<select ng-model="ss">
<option>请选择</option>
<option selected="selected">1000-2000</option>
<option>2000-3000</option>
<option>3000-4000</option></select><br />
<table ng-show="show()" style="margin-top: 50px;" align="center" cellpadding="5" cellspacing="0" border="1px solid #000">
<thead>
<tr>
<th ng-click="desc=!desc;col='id'">产品编号</th>
<th ng-click="desc=!desc;col='name'">产品名称</th>
<th ng-click="desc=!desc;col='price'">产品价格</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="l in list | filter:{'name':query} | orderBy:col:desc; " ng-if="money(l.price)">
<td>{{l.id}}</td>
<td>{{l.name}}</td>
<td>{{l.price | currency:"(RMB)"}}</td>
<td><button ng-click="del(l.name)">删除</button></td>
</tr>
</tbody>
</table>
<p ng-if="!show()">购物车为空</p>
</body>
</html>
相关文章推荐
- html angular购物车全选+全删+批量删除+单独删除+模糊查找+筛选价格区间
- 购物车angularJS删除和模糊查询还有排序
- AngularJS实现购物车功能,表格的删除,查询,排序功能
- JSP类似购物车根据后台数据自动生成一行商品,点击按钮实现数量价格自动增加
- c语言实现通讯录,包括增加名字,删除信息,查找,修改,排序
- 地址邮编, 用CoreData实现插入/删除/查询(包含结果排序,模糊查询)
- AngularJS购物车模糊查询,表头排序,增删改查
- AngularJS模糊查询功能实现代码(过滤内容下拉菜单排序过滤敏感字符验证判断后添加表格信息)
- (angularjs) 数据的增查(添加用户,查询名字,实现排序,判断非空 ,是否是数字,是否重名,敏感字符)
- angular js 实现购物车模糊查询删除全选
- AngularJS 查询、添加、删除、全选、反选、点击排序
- AngularJs的点击删除,排序,查询
- 蓝桥杯 区间k大数查询(排序+查找)
- 【通讯录系统】:实现一个通讯录(可添加、删除、修改、查找、显示、清空、排序)
- Oracle查找排序,模糊查询,外连接
- 【通讯录系统】:实现一个通讯录(可添加、删除、修改、查找、显示、清空、排序)
- 3:AngularJS:模糊查询过滤内容,下拉菜单排序,过滤敏感字符,验证判断后添加表格信息
- 算法训练1.区间k最大数查询(排序 查找)
- GridView 实现自定义分页、排序、查询、添加、编辑、多选删除 之代码规范
- SQL语句实现按关健字模糊查询,并按匹配度排序