Как извлечь значения «myanswer» из массива User с помощью Angularfire2? - PullRequest
0 голосов
/ 10 июля 2019

снимок экрана базы данных Как извлечь значения 'myanswer' из массива User?Я хочу получить доступ к Rightanswers из массива myanswer?


  constructor(private db: AngularFireDatabase,
              private auth: AngularFireAuth) {
                this.auth.authState.subscribe(user => {
                  if (user) {
                     this.userId = user.uid;
                     return this.db.list(`users/${this.userId}`);
                  } else {
                    return of(null);
                  }
               });
               this.scoreRef = db.list('user');
               this.scores = this.scoreRef.snapshotChanges();
              }

  getScores() {
    return this.db.list('users', ref => ref.orderByChild(`${this.userId}`))
    .snapshotChanges();
  }

  ngOnInit() {
    this.getScores()
    .pipe(
      map(actions => actions.map(a => {
        const data = a.payload.val() as any;
        const id = a.payload.key;
        return { id, ...data };
      })))
     .subscribe(action => {
      this.scores = action;  // How should i get myanswer array here
    });
}
...