angularJs 增加 删除 排序
2017-09-21 13:45
155 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script type="text/javascript" src="js/angular.js" ></script> <script> var app = angular.module("myApp",[]); app.controller("myCtrl",function($scope){ //添加数据 $scope.bx =[ {id:1234,name:'ipad',price:3400,kc:10}, {id:1244,name:'aphone',price:5400,kc:30}, {id:1334,name:'mypad',price:3600,kc:15}, {id:8234,name:'zpad',price:7400,kc:16} ]; //删除 $scope.shan = function(index){ $scope.bx.splice(index,1); }; //批量删除 $scope.plsc =function(index){ $scope.bx.splice(index); }; //排序 $scope.orderColumn='name'; $scope.orderSign='-'; $scope.sort = function(sortColumn){ $scope.orderColumn=sortColumn; if($scope.orderSign=='-'){ $scope.orderSign=""; }else{ $scope.orderSign="-"; } }; }); </script> </head> <link rel="stylesheet" href="css/zk.css" /> <body ng-app="myApp" ng-controller="myCtrl"> <div id="bos"> <div id="s"> <input type="text" id="search" ng-model="search" placeholder="输入关键字..." /> <button class="pl" ng-click="plsc($index)" >批量删除</button> </div> <div id="x"> <table> <tr> <td><input type="checkbox" ng-model="qx"/></td> <td ng-click="sort('id')">商品编号</td> <td ng-click="sort('name')" style="color: red;">商品名称</td> <td ng-click="sort('price')">商品价格</td> <td ng-click="sort('kc')">商品库存</td> <td>数据操作</td> </tr> <tr ng-repeat="x in bx | filter:{'name':search}|orderBy:(orderSign + orderColumn)"> <td><input type="checkbox" ng-checked="qx"/></td> <td>{{x.id}}</td> <td>{{x.name}}</td> <td>{{x.price | currency:'¥:'}}</td> <td>{{x.kc}}</td> <td><button style="background: orange;" ng-click="shan($index)">删除</button></td> </tr> </table> </div> </div> </body> </html>
相关文章推荐
- angularJS 增加 删除 修改 查询 排序
- AngularJs表格 增加、删除、关键字查询、按数量排序
- AngularJS在页面对表格进行增加、查询、排序
- 实现一个简单的菜单程序,运行时显示"Menu:A(dd) D(elete) S(ort) Q(uit),Select one: "提示用户输入。输入A、D、S时分别提示"数据已经增加、删除、排序"
- 使用javascript操作多选列表框,实现动态增加删除,左右移动,上下排序移动等功能。
- HTML,angularJS表格内容排序,点击删除,删除当前,输入内容显示包含内容的数据
- 具有排序,增加,删除,翻页动画的scrollview
- AngularJS 查询 删除 增加 修改
- AngularJs添加删除排序Y
- 双向循环链表函数(有删除,增加,排序,统计等功能)
- 封装链表库实现单链表:增加,删除,查询,修改,排序,逆转
- 链表的java实现以及基本的增加,删除,排序操作
- AngularJS网络请求数据、删除、查找、 排序
- jQuery表格常用操作方法-增加,查询,删除,排序,移动,全选
- Arrays 类如何使用,数组的复制,数组排序,数组增加删除,变换位置
- AngularJs球员的增加查询排序的方法
- 采用JavaScript、AngularJS实现过滤器搜索、删除、添加、排序、常用过滤器
- Angularjs全选 反选 批量删除 修改 排序
- AngularJS过滤器filter,orderBy排序,删除全部数据2
- JavaScript实现下拉列表框数据增加、删除、上下排序的方法