1

There is an object. It is dynamic and the data in it are constantly changing, say so.

$scope.object = {
    "className": "?????",
    "property": [
        {
            "name": "???"
        },
        {
            "prado": "???"
        }
    ]
}

What needs? And it is necessary for the project $scope.object monitor any change in, at all levels of the object. Maybe there is a method similar to the $watchCollection, only advanced? Or another way to keep track of?

I would be glad of any tip. Thank you in advance!

000
  • 26,951
  • 10
  • 71
  • 101
pr0r0k131
  • 15
  • 4
  • What would be the reason to watch the entire object if angularjs does the update in UI for you? – Diana R Sep 05 '15 at 11:17

1 Answers1

0

$watch has third optional parameter:

$watch(watchExpression, listener, [objectEquality]);

According to documentation:

When objectEquality == true, inequality of the watchExpression is determined according to the angular.equals function. To save the value of the object for later comparison, the angular.copy function is used. This therefore means that watching complex objects will have adverse memory and performance implications.

See https://docs.angularjs.org/api/ng/type/$rootScope.Scope

See also How to deep watch an array in angularjs?

But use it carefully.

Community
  • 1
  • 1
Robert Goldwein
  • 5,805
  • 6
  • 33
  • 38