Working with large datasets in AngularJS

First of all: I think this question applies to most if not all of today's JavaScript MVWTF frameworks that feature a persistence layer.

My current task is to rewrite the comment administration section of a website in Angular to speed up the workflow of those who have to approve or mark comments as spam. The website already has a fairly large number of comments and more are coming in each day.

The question is: how do I handle this dataset in Angular? All the examples I saw are fine and dandy but all of them work with small arrays of data.

We brainstormed a couple of ideas, the best one being: Download the latest X comments when starting the JS app and then when searching or refining the list after applying an Angular filter on the existing (client side) dataset pull the matching data from the server (or a subset of the matching data if we're paginating) and merge it with the data we already have on the client. This way the data on the client will get more and more extensive and subsequent client side searches will hopefully get more and more precise.

Hopes this makes sense.

Any other ideas?

Thanks.

The biggest thing you'd have to be careful of is bloat created by duplicating the large object/array in multiple scopes throughout your app. This can be caused simply by putting the large object in a controller's $scope, then passing it to a directive's $scope (ng-repeat for example). A good way to investigate this in your app would be to check out Angular Batarang

If this huge amount of data is something you're going to be using among multiple controllers, directives and services (which I assume it is), it's probably a good idea to place it in $rootScope or possibly it's own service. The case for $rootScope would be if you just want to store it as data and access it however you please. The case for a service would be if you want to have reusable methods to query/addto/deletefrom the large block of data, you might even have the service handle the $http.get of the data as well.

I hope that helps.