1

I have one issue that one of companies has so many data that make to load so long to be displayed in my AngularJs project. Sometimes, it does not appear when kind of connection is cut off or request time out. At that time, what my client is to show some message and re-run that function again to reload data. Backend is using NodeJS.

Please help me how to full-fill my client's request.

Here is my code to get data from backend.

$scope.tableParams = new ngTableParams({
    page: 1, // show first page
    count: 20, // count per page
    sorting: {
        title: 'asc' // initial sorting
    },
    filter: {
        title: filterText,
        is_active: $scope.IsActive
    }
}, {
    total: 0,
    getData: function ($defer, params) {
        companyService.getDataBelongToCompany($scope.companyId, params.url()).then(function (data) {
            params.total(data.total);
            $defer.resolve(data.jobs);
            $scope.collapsed = false;
        }, function () {
            $defer.resolve([]);
        });
    }
});
3
  • With pagination, this issue should not arise... Commented May 26, 2016 at 8:25
  • @Rayon tableParams has pagination itself. Commented May 26, 2016 at 8:58
  • That is what I mean... Commented May 26, 2016 at 9:28

2 Answers 2

1

I think that what you need is to use a server-side pagination. If the response takes so long you should limit the data sent by your backend and paginate it because it will affect the user experience.

Here you can find more information about how to paginate with ngTable:

ngTable pagination documentation

Sign up to request clarification or add additional context in comments.

Comments

0

one method is to add timeout in http request as below

$http.get('url', {timeout: 5000}); if it takes more than 5 secs you can show message in .error() function

Check this answer for more details How to set a global http timeout in AngularJs

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.