here is my code in jsfiddle除去空数组在多维数组
var app = angular.module("app", []);
app.controller("MyCtrl1", MyCtrl1);
function MyCtrl1($scope) {
$scope.block = new Array();
$scope.block[0] = new Array();
$scope.block[0].push("111");
$scope.block[0].push("112");
$scope.block[0].push("113");
$scope.block[0].push("114");
$scope.block[0].push("115");
$scope.block[2].length = 0;
$scope.block[3] = new Array();
$scope.block[3].push("111");
$scope.block[3].push("112");
$scope.block[3].push("113");
$scope.block[3].push("114");
$scope.block[3].push("115");
$scope.block.filter(Boolean);
console.log($scope.block.length.toString());
}
[[ “111”, “112”, “113”, “114”, “115”],[ “111”, “112”,” 113" , “114”, “115”],[],[ “111”, “112”, “113”, “114”, “115”]]
如何删除空数组 感谢帮助〜
伟大的! 这种方法也非常好,非常感谢 – Duke 2015-04-03 15:00:24
@ user3382559只有当您事先知道要移除的项目(并且不会一次移除多个项目)时,这才会起作用。 – JLRishe 2015-04-03 15:07:46
@JLRishe好〜谢谢你提醒我,我会注意这些 – Duke 2015-04-03 15:33:54