I have an object of arrays... The array can contain blanks, how can i create an ANgular filter to remove the blanks to determine the length of the array?
$sc
At first I want to note, that your JS object is invalid.
Please, use the array of arrays instead of object of arrays in this case.
$scope.myData = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "", "", "", "", "", "", "", "", "" ],
["1", "2", "3", "4", "5", "6", "7", "8", "", "", "", "", "", "", "", "", "", "" ],
["1", "2", "3", "4", "5", "6", "7", "", "", "", "", "", "", "", "", "", "", "" ],
["1", "2", "3", "4", "5", "6", "", "", "", "", "", "", "", "", "", "", "", "" ]
];
And secondly i've created filter to remove the blank items.
.filter('removeBlankItems', function() {
return function(inputArray) {
var outArray = [];
for (var i = 0; i < inputArray.length; i++) {
if(inputArray[i].length != 0){
outArray.push(inputArray[i]);
}
}
return outArray;
};
})
This is JSFiddle with working example.