angular.min.1.2.js
js获取数据investService.getNewStacksList().success(function(response){ if(response.op.code == "Y"){ var tempInfomationList = []; angular.forEach(response.list,function(newstack){ tempInfomationList.push(newstack); }); $scope.col = "sub_bgn_dt_on"; //默认按sub_bgn_dt_on字段排序 $scope.newstackslist = tempInfomationList; } $scope.$apply(); });
2、定义一个filter,以便前端的html使用angular.module("gp").filter("newstacksFilter",function(){return function(newstackslist,s_val){var tempInfomationList = [];angular.forEach(newstackslist,function(newstackInfo){if(s_val!=null && s_val!=""){if((newstackInfo.trd_code).indexOf(s_val)>=0 || (newstackInfo.secu_sht).indexOf(s_val)>=0){tempInfomationList.push(newstackInfo);}}else{tempInfomationList = newstackslist;}});return tempInfomationList;}})
最后效果图:注:点击表头文字链可进行排序。如:点击“发行价格”按发行价格排序
主要是注意filter这一块