title: How to reload grid after every 5 seconds in angular js?
body: <p>I am using angular js and using and I want to reload grid after every 5 seconds.</p>
  
  <p>My angular js code for build grid is as bellow:</p>
  
  <pre><code>App.controller('NGTableCtrl', NGTableCtrl);
  
  function NGTableCtrl($scope, $filter, ngTableParams, $resource, $timeout, ngTableDataService) {
    'use strict';
    // required for inner references
    var vm = this;
    var data = [
    {name: "Moroni",  age: 50, money: -10   },
    {name: "Tiancum", age: 43, money: 120   },
    {name: "Jacob",   age: 27, money: 5.5   },
    {name: "Nephi",   age: 29, money: -54   },
    {name: "Enos",    age: 34, money: 110   },
    {name: "Tiancum", age: 43, money: 1000  },
    {name: "Jacob",   age: 27, money: -201  },
    {name: "Nephi",   age: 29, money: 100   },
    {name: "Enos",    age: 34, money: -52.5 },
    {name: "Tiancum", age: 43, money: 52.1  },
    {name: "Jacob",   age: 27, money: 110   },
    {name: "Nephi",   age: 29, money: -55   },
    {name: "Enos",    age: 34, money: 551   },
    {name: "Tiancum", age: 43, money: -1410 },
    {name: "Jacob",   age: 27, money: 410   },
    {name: "Nephi",   age: 29, money: 100   },
    {name: "Enos",    age: 34, money: -100  }
   ];
   // SELECT ROWS
   vm.data = data;
   vm.tableParams3 = new ngTableParams({
    page: 1,            // show first page
    count: 10          // count per page
    }, {
    total: data.length, // length of data
    getData: function ($defer, params) {
        // use build-in angular filter
        var filteredData = params.filter() ?
                $filter('filter')(data, params.filter()) :
                data;
        var orderedData = params.sorting() ?
                $filter('orderBy')(filteredData, params.orderBy()) :
                data;
  
        params.total(orderedData.length); // set total for recalc pagination
        $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
    }
  });
  
  // EXPORT CSV
    var data4 = [{name: "Moroni", age: 50},
    {name: "Tiancum", age: 43},
    {name: "Jacob", age: 27},
    {name: "Nephi", age: 29},
    {name: "Enos", age: 34},
    {name: "Tiancum", age: 43},
    {name: "Jacob", age: 27},
    {name: "Nephi", age: 29},
    {name: "Enos", age: 34},
    {name: "Tiancum", age: 43},
    {name: "Jacob", age: 27},
    {name: "Nephi", age: 29},
    {name: "Enos", age: 34},
    {name: "Tiancum", age: 43},
    {name: "Jacob", age: 27},
    {name: "Nephi", age: 29},
    {name: "Enos", age: 34}];
  
    vm.tableParams4 = new ngTableParams({
    page: 1,            // show first page
    count: 10           // count per page
    }, {
    total: data4.length, // length of data4
    getData: function($defer, params) {
        $defer.resolve(data4.slice((params.page() - 1) * params.count(), params.page() * params.count()));
    }
    });
  
  
    // SORTING
    vm.tableParams = new ngTableParams({
    page: 1,            // show first page
    count: 10,          // count per page
    sorting: {
        name: 'asc'     // initial sorting
    }
    }, {
    total: data.length, // length of data
    getData: function($defer, params) {
        // use build-in angular filter
        var orderedData = params.sorting() ?
                $filter('orderBy')(data, params.orderBy()) :
                data;
  
        $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
    }
    });
  
    // FILTERS
    vm.tableParams2 = new ngTableParams({
    page: 1,            // show first page
    count: 10,          // count per page
    filter: {
        name: '',
        age: ''
        // name: 'M'       // initial filter
    }
    }, {
    total: data.length, // length of data
    getData: function($defer, params) {
        // use build-in angular filter
        var orderedData = params.filter() ?
               $filter('filter')(data, params.filter()) :
               data;
  
        vm.users = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
  
        params.total(orderedData.length); // set total for recalc pagination
        $defer.resolve(vm.users);
    }
    });
  
    }
  </code></pre>
  
  <p>If I am using setTimeout inside the function then it is not refreshing new values.</p>
  
  <p>Any help/suggestion would be appreciated.</p>