How 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.

  1. 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;  
  2. add empty filter function with ng-repeat
    <li ng-repeat="x in students| emptyFilter"></li>

Note: here students is a array variable.

I hope you all will enjoy my this post 🙂


Sr. Software Engineer

Tagged with: , , ,
Posted in Angular JS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Recent Posts
%d bloggers like this: