I am trying to watch my firebase array for changes and call a function when the changes take effect.
I have achieved this however, I am not able to get the key
that firebase uses to store the data so I can pass it onto my function I am calling.
The key being -JrFJO3-vJ8DBHovapub
or the top most child of a node like estimates
estimates
{
-JrFJO3-vJ8DBHovapub
{
....
}
....
}
My current code looks like such:
$scope.estimates.$watch(function(data) {
if(data.event == "value") {
angular.forEach($scope.estimates, function(estimate) {
es.findTotal();
});
}
});
Is what I have right now. How do I obtain the key when a value event is called?
Why not use the new value
data
, instead of$scope.stimates
?