【发布时间】:2018-08-25 19:04:36
【问题描述】:
我有这个 Firebase 数据库:
我需要获取 alii-b9d94 的所有 uid(子代)。但问题是:当我将它作为对象获取时,我无法访问该对象以从中获取值。
这是我能够获得但无法访问的内容:
ts 代码:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import firebase from 'firebase';
import { AuthService } from '../../services/auth';
import { InfoService } from '../../services/info';
@IonicPage()
@Component({
selector: 'page-dash',
templateUrl: 'dash.html',
})
export class DashPage {
constructor(public navCtrl: NavController,
public navParams: NavParams,
private infoService: InfoService,
private authService: AuthService) {
firebase.database().ref().on('value', (snap) => {
let rootVals = snap.val();
let uids : string[] = [];
/* I am trying to access this by this code but not working :(
I knew the problem with .this but Is there any other way i can through it
retrieve every child in a single variable */
console.log(rootVals.this.uids);
console.log("rootVals");
console.log(rootVals);
} );
}
}
如何获取每个孩子并将其存储在单个变量中?
【问题讨论】:
标签: typescript firebase firebase-realtime-database ionic3