How do I go about displaying the data that I've retrieved from my firebase database? I need to be able to display the data and organize it in the HTML file. As a starter, I want to simply show the customer user's first. I would also like to make this clickable eventually because I plan on putting thin user's data into a modal page. Also, I am not sure as to how this will work when there are multiple users in the database, so if someone could explain that process, it would be much appreciated. I've attached a picture of my database and the Javascript and HTML files. All help is appreciated. Thanks.
My Database Model
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController, Modal } from 'ionic-angular';
import { DriverHomePage } from '../driver-home/driver-home';
import { CustomerModalPage } from '../customer-modal/customer-modal';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
import * as firebase from 'firebase';
/**
* Generated class for the DriverHomePage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-driver-home',
templateUrl: 'driver-home.html'
})
export class DriverHomePage {
const custRef = firebase.database().ref().child('User').orderByChild('type').equalTo('customer').on('value', function(snapshot) {
snapshot.forEach(function(child) {
var data = child.val();
console.log(data.firstName + ' ' + data.lastName + ' ' + data.location );
});
}, function(error) {
// The Promise was rejected.
console.log('Error: ',error);
});
constructor(private modalCtrl: ModalController, private afAuth: AngularFireAuth, private afDatabase: AngularFireDatabase, public navCtrl: NavController, public navParams: NavParams) {
}
/*openModal(){
//const custData
const custModal: Modal = this.modalCtrl.create('CustomerModalPage');
custModal.present();
custModal.onDidDismiss();
}*/
ionViewDidLoad() {
console.log('ionViewDidLoad DriverHomePage');
}
}
<!--
Generated template for the DriverHomePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>driver-home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<div padding>
<p>I WANT TO DISPLAY FIRST NAME HERE</p>
</div>
</ion-content>
