2

Reading through Misko's excellent answer on databinding here: How does data binding work in AngularJS?, I am wondering how Angular does it's dirt-checking behind the scenes, because:

I'm creating an app, that prints a large amount of Car objects to the DOM, each Car looking something like this:

var Car = function(settings) {
    this.name = settings.name;
    + many more properties...
}
Car.prototype = {
    calcPrice: function() { ... },
    + many more methods...
}

$scope.cars = [lots of Cars];

The linked answer above mentions a limit of around 2000 values that can be provided through databinding when printed in the DOM, and due to the large amount of properties on each Car object, this number could very easily be exceeded in this app when looping through the cars array.

Say you end up having 2000+ values printed in the DOM through databinding, and one of these values updates, does it affect Angular's dirt-checking performance that 2000 values are present, or does Angular somehow flag the values that change, so it only looks at the changed values when running its $digest()? In other words, does it matter that you have a lot of databound values, when only a very small number of these are likely to be updated after the initial print?

If it does matter, -- and since most of the values are read-only -- is there some way to use the databinding syntax {{car.prop}} to get the value to the DOM once and then tell Angular to not bind to them anymore

Would it make a difference to add getter-methods to the Car object and provide it's properties like this {{car.getProp()}} ?

Community
  • 1
  • 1
acrmuui
  • 2,040
  • 1
  • 22
  • 33

1 Answers1

1

I had the same kind of problem with an application I was working on. Having a huge data set is not a problem, the problem comes from the bindings,ng-repeats in particular killed performances. Part of the solution was removing "dynamic" bindings with "static" bindings using this nice library: http://ngmodules.org/modules/abourget-angular.

Yann
  • 2,211
  • 1
  • 15
  • 14