Use array-view Instead of Angular’s Filters

AngularJS uses dirty checking to discover when changes have occurred to the data it is displaying on-screen. This simplifies your code. It speeds up development. And it allows you to use whatever-the-heck you want for your data and models, instead of forcing you to use their model classes (as Ember and Backbone require).

Dirty checking also re-runs filters. A lot.

Checking whether 32 has changed to 33 isn’t a big deal. Checking whether an array that, using Angular’s filters, is sorted and filtered by re-sorting and re-filtering the original is slightly more expensive. Doing that on every $digest (e.g. every key-stroke in an input field), especially on large arrays, could kill performance on slower machines and mobile.


Introducing array-view. array-view is a library that provides a sorted, filtered, even paginated view onto your original array. The view is an actual array that stays in sync with your original, so any push/pop/shift/etc will affect both arrays. And the best part, the view syncs only when required, not whenever $digest is run.

You can even use array-view to simply keep an array sorted automatically whenever you add new objects to it. It’s simple and easy to use.

And the best part: it’s still an array. Any library expecting arrays can use it. You can use it in your JavaScript SDK you provide for customers.