Angularjs添加排序查询功能的实例代码

前端之家收集整理的这篇文章主要介绍了Angularjs添加排序查询功能的实例代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

废话不多说了,直接给大家贴代码了,具体代码如下所示:

Meta charset="UTF-8"> @H_403_8@ var app=angular.module("myapp",[]); app.controller("myCtrl",function($scope){ $scope.h=false;//显示和隐藏添加列表 $scope.persons=[];//存放添加内容 $scope.xz=function(){//新增球员的点击事件点击列表出现 $scope.h=true; } $scope.tj = function(){ for(var i=0;i<$scope.persons.length;i++){//遍历列表的所有数据 if($scope.name==$scope.persons[i].name) {//对比数据没有重复的姓名出现 alert("您记录的内容已存在"); return; } } //判断不能为空 if($scope.name!=""&&$scope.name!=null){ if($scope.wz!=""&&$scope.wz!=null){ if($scope.hao!=""&&$scope.hao!=null){ if($scope.number!=""&&$scope.number!=null){ $scope.persons.push({//添加 name:$scope.name,wz:$scope.wz,hao:$scope.hao,number:$scope.number}); $scope.name=""; $scope.wz=""; $scope.hao=""; $scope.number=""; $scope.h=false;//添加成功添加表格关闭 }else{ alert("票數不能為空"); } }else{ alert("球号不能为空"); } }else{ alert("位置不能为空"); } }else{ alert("姓名不能为空"); } } }); 查询