As a beginner in coding, I would greatly appreciate a simple answer.
I am attempting to treat a Firebase object as a JavaScript array for use in HTML via $scope. What is the most effective approach?
Database: database
Current code:
var mainApp = angular.module("bookWorm", []);
mainApp.controller('bookController', function($scope, $http) {
var ref = firebase.database().ref("Fiction");
ref.once("value", function(snapshot) {
console.log(snapshot.val());
$scope.fiction = snapshot.val();
});
});
<div class="contents">
<div class="heading">
<h2 style="text-align:center">Fiction</h2>
</div>
<u1 style="cursor:pointer">
<li ng-repeat="content in fiction"><img src="assets/fiction/{{content.book}}.png" width="200px" height="200px"></li>
</u1>
</div>
The console displays the following:
Object {-Km712C_iBij3OkXCR1s: Object, -Km71G_rHgirXWZi1xh6: Object, -Km71Rje4ZeluNYtK8x_: Object, -Km71gTdrfgC1BeXIPPU: Object, -Km71x6C-s_FFTcEMYCc: Object…}
In which I am unable to list the "book" elements. Any help with examples would be appreciated.