My web application uses Firebase JS and AngularJS to display a list of event registrations and the users who have registered for each event. The events and the users' data are in different database nodes.
Database:
"event_registrations" : {
"$event_id" : {
"$user_id" : {
"registration_date" : "..."
"total_amount" : "...",
}
}
},
"users" : {
"$user_id" : {
"events" : {
"event_id" : 1
},
"profile" : {
"email" : "..."
"name" : "...",
// ...
}
},
}
Angular:
function MyController($scope, $firebaseObject) {
// Retrieve event data
$scope.events = scope.firebaseRef.child('event_registrations');
// Retrieve user_data
$scope.getUserData = function(userID) {
var ref = $firebaseObject(scope.firebaseRef
.child('users')
.child(userID)
.child('profile'));
ref.$ref().once("value", function(dataSnapshot) {
var data = dataSnapshot.val();
$scope.user_data = data;
});
};
}
Web page:
<div ng-repeat="event in event_registrations">
<table>
<tr>
<tr ng-repeat="(user_id, user_data) in event">
{{getUserData(user_id)}}
<td>{{user_data.email}}</td>
<td>{{user_data.name}}</td>
</tr>
</tbody>
</table>
</div>
The problem is that when getUserData()
is called from the web page, a 10 $digest() iterations reached
error is produced and the data on the web page stops updating in realtime when it is updated in the Firebase DB.
How can this be solved? I have looked at Firebase-Util but am unsure how to specifically utilize it in this case.