My HTML is
<tbody>
<tr ng-repeat="question in questions">
<td>
<a ui-sref="englishDetail({id: question.id})">
{{ question.id }}
</a>
</td>
<td>{{ question.instruction }}</td>
<td>{{ question.questionText }}</td>
<td>{{ question.level }}</td>
<td>
<a ui-sref="passageDetail({id: question.passageId})">
{{ question.passageId }}
</a>
</td>
</tr>
</tbody>
In my controller, I have
var fbase;
$scope.questions = [];
fbase = new Firebase("https://my.firebaseio.com");
fbase.child("questions").orderByChild("subject").equalTo("english").once("value", function(questionsSnapshot) {
$scope.questions = [];
questionsSnapshot.forEach(function(questionSnapshot) {
$scope.questions.push({
id: questionSnapshot.key(),
instruction: questionSnapshot.val().instruction,
questionText: questionSnapshot.val().questionText,
level: questionSnapshot.val().level,
passageId: questionSnapshot.val().passageId
});
});
return $scope.$apply();
});
It somehow seems unnecessary to have to iterate over the returned object to achieve what I am trying to do. Is there a better / more native way of doing this? I've looked into the supposed three way data binding on the Firebase doc site but that doesn't show how to do it if you are filtering objects.