全局变量定义:
1 /** 2 *删除数组指定下标或指定对象 3 */ 4 Array.prototype.remove=function(obj){ 5 for(var i =0;i <this.length;i++){ 6 var temp = this[i]; 7 if(!isNaN(obj)){ 8 temp=i; 9 } 10 if(temp == obj){ 11 for(var j = i;j <this.length;j++){ 12 this[j]=this[j+1]; 13 } 14 this.length = this.length-1; 15 } 16 } 17 }
删除方法:
1 $scope.removeByValue = function(arr, val) { 2 for(var i=0; i<arr.length; i++) { 3 if(arr[i] === val) { 4 arr.splice(i, 1); 5 break; 6 } 7 } 8 }; 9 $scope.unSuspectAll = function(data) { 10 var item = data.suspectList; 11 for(var i=0;i<item.length;i++){ 12 13 $scope.removeByValue($scope.SuspectFrom.ids1,item[i].suspectId); 14 } 15 };
转载于:https://www.cnblogs.com/miny-simp/p/7776690.html