- Define a new function in your controller file
app.filter('emptyFilter', function() { return function(array) { var filteredArray = []; angular.forEach(array, function(item) { if (item) filteredArray.push(item); }); return filteredArray; }; });
- add empty filter function with ng-repeat
<ul> <li ng-repeat="x in students| emptyFilter">x.name</li> </ul>
How to remove NULL value from array in Angular JS?
Hello Friends!
I hope you are doing well.
This my first post on angular JS. I was getting a issue during ng-repeat loop in IE8 browser, loop was working fine in all browsers but in IE8, it was repeating one more extra time. that's mean if actual loop is running 4 time then same loop is repeating 5 times in IE8, means one time extra.
During review issue i have found that in array there were a null value was adding by default in IE8 browsers and that's why loop was running one extra time.
If you are also getting this type of issue then you can try given below steps for resolved to issue.