我开始使用Firebase 3,并对如何对数据库进行一些查询感到困惑。
基本上,我有一个示例数据集,如下所示:
{
"people":[
{
"name": "fred smith",
"gender": "male",
"age": 30,
"images":
{
"image_main": "images/image1_main.jpg",
"image_thumb": "images/image1_th.jpg"
}
},
{
"name": "mary hairy",
"gender": "female",
"age": 25,
"images":
{
"image_main": "images/image2_main.jpg",
"image_thumb": "images/image2 _th.jpg"
}
}
]
}
该应用程序设置如下:
var myApp = angular.module('myApp', ['ngRoute', 'firebase']);
myApp.config(['$routeProvider', function($routeProvider) {
//set up the firebase config
var config = {
apiKey: "XXX",
authDomain: "project-XXX.firebaseapp.com",
databaseURL: "https://project-XXX.firebaseio.com",
storageBucket: "project-XXX.appspot.com",
};
firebase.initializeApp(config);
}]);
因此,我已将json数据集导入firebase并进行了适当的设置。
这个控制器是:
myApp.controller("PeopleController",
["$scope", "$firebaseArray", function($scope, $firebaseArray) {
var ref = firebase.database().ref('people');
var people= $firebaseArray(ref);
$scope.people = people;
console.log($scope.people);
好的,到目前为止一切顺利。我可以根据需要通过people对象获取人员和html中的ng-repeat循环。
现在,我如何获得对图像的引用。我希望能够抓住每个人并显示image_main和image_thumb,但无法知道如何执行此操作。
由于