tobbbe
2/18/2016 - 12:23 PM

angular $watch $watchGroup $watchCollection

angular $watch $watchGroup $watchCollection

$scope.$watch('vm.object.property', doThing) // will only watch vm.object.property

$scope.$watch('vm.object', doThing, true) // will DEEP watch EVERYTHING on vm.object

$scope.$watchGroup(['vm.object.property','vm.object.property2'], doThing) // will watch vm.object.property AND vm.object.property2

$scope.watchCollection('vm.object', doThing) // will watch for changes on EVERY property on vm.object. BUT only at first level => YES: vm.object.property and vm.object.property2, NO: vm.object.property.thing