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?
$scope.myData = {
["1", "1", "4", "4", "N", "4", "6", "8", "", "", "", "", "", "", "", "", "", "", ],
["2", "2", "4", "6", "0", "6", "5", "4", "2", "", "8", "", "", "", "", "", "", "", ],
["2", "3", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ],
["3", "F", "D", "3", "5", "1", "D", "5", "", "", "", "", "", "", "", "", "", "", ],
["1", "V", "4", "4", "3", "2", "1", "1", "4", "", "", "", "", "", "", "", "", "", ],
["4", "5", "8", "6", "4", "2", "8", "7", "1", "1", "2", "", "", "", "", "", "", "", ],
["4", "4", "R", "F", "D", "8", "4", "2", "4", "8", "7", "4", "8", "", "", "", "", "", ],
["D", "5", "F", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ],
["1", "4", "1", "3", "4", "B", "D", "G", "", "", "", "", "", "", "", "", "", "", ]
}
HTML:
<div ng-repeat="data in myData">
<div ng-show="(data | myFilter).length > 10">
Show if length greater than 10
</div>
<div ng-show="(data | myFilter).length > 15">
Show if length greater than 15
</div>
</div>
Thanks
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.
And secondly i've created filter to remove the blank items.
This is JSFiddle with working example.
Use this link https://github.com/a8m/angular-filter
It gives you a number of ways to filter whatever you need in any format.It also has examples along with each filter.
The other answers didn't work for me and angular-filter doesn't have any specific abilities for this case, but the following worked in my Angular app. No custom filter needed.
Browser compatability: http://kangax.github.io/compat-table/es5/#Array.prototype.filter