Cant access values on a list on firebase


I have a list of items I need to show on the screen.

But the main problem is… These values are stored using authentication, this means that if I log as use A, there will be user A’s saved items, if I log as user B, there will be user B’s different from A’s saved item.

I cant show the items using the ngFor because I need to pass the authentication node to show that particular user’s items.

How can I do this?

the html code

  Generated template for the AgendaPage page.

  See for more info on
  Ionic pages and navigation.



<ion-content padding>
        <ion-item *ngFor="let item of calculoList$ | async">
          Litros Abastecidos: {{item.litros}} <br/>
          Valor Pago: R$ {{item.valorPago}} <br/>
          Consumo Médio do Carro: {{item.resultado}} km/l

the .ts code

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Observable } from 'rxjs/Observable';
import { Calculo } from '../../models/calculo';
import { calculoService } from '../../services/lista-calculo/calculoService';
import { HomePage } from '../home/home';

 * Generated class for the AgendaPage page.
 * See for more info on
 * Ionic pages and navigation.

  selector: 'page-agenda',
  templateUrl: 'agenda.html',
export class AgendaPage {

  calculoList$: Observable<Calculo[]>

  constructor(public navCtrl: NavController, public navParams: NavParams,
    private calculo: calculoService) {
    this.calculoList$ = this.calculo
          changes => {
            return => ({
              key: c.payload.key, ...c.payload.val()

  ionViewDidLoad() {
    console.log('ionViewDidLoad AgendaPage');


the service code

import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { Calculo } from '../../models/calculo';
import { AngularFireAuth } from 'angularfire2/auth';

export class calculoService{
    private calculoListRef = this.afDatabase.list<Calculo>('consumo');

    constructor(private afDatabase: AngularFireDatabase, private afAuth: AngularFireAuth, ){


        return this.calculoListRef;

    addItem(calculo: Calculo){
        return this.afAuth.authState.take(1).subscribe(auth => {

I want the items inside “consumo”->“b1AnCjVh7Laj1nvRgkt9Zio1URr1” to show



First, use Firestore, not Firebase, unless there is an extra special reason you need Firebase.

Second, set up your access rules so both users can read from the same node. I divide my User object into PublicUserData and PrivateUserData, and have different backend access rules for each.


Thanks Mr. Sterling!!!