Monday, 2 July 2018

Retrieving data in a list from firebase database table

I have a Profile table in my firebase database that looks like this enter image description here
What I am trying to do is to grab certain values from this table for each instance of profile and list them in the UI. I found another stack overflow post and the solution that worked for them was like this...
here is the home.ts file (this will be where I display up all the users)
import { Component } from '@angular/core';
import { NavController, ToastController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, AngularFireObject } from 'angularfire2/database';
import { Profile } from '../../models/profile';
import { Observable } from 'rxjs/Observable';
import { HttpClient } from'@angular/common/http';

import firebase from 'firebase';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  profiles:Observable<any>;
  constructor(public http: HttpClient, private toast: ToastController, 
public afDatabase: AngularFireDatabase, private afAuth: AngularFireAuth, 
public navCtrl: NavController, public navParams: NavParams) {
    let profiles = this.afDatabase.list('profile').valueChanges();
  }
  }

And then in the home.html file, I am trying to display it like this..
<ion-list>
      <ion-item *ngFor="let profile of profiles | async">
        <p></p>
        <p></p>
      </ion-item>
  </ion-list>

I get 0 errors, but absolutely nothing is populating. No values are showing on the UI! Any ideas here as to what could be going wrong?


from Retrieving data in a list from firebase database table

No comments:

Post a Comment