Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

464
Views
How to display firebase subcollections in ionic hmtl?

I'm new to Angular and Ionic, so, sorry for question.

I have subcollection in firebase, and I could retrieve and display in console. console image

But I want to display it in HTML.

typescript page

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../services/auth.service';
import { Router } from '@angular/router';
import { AngularFirestore } from '@angular/fire/compat/firestore';

@Component({
  selector: 'app-my-reservations',
  templateUrl: './my-reservations.page.html',
  styleUrls: ['./my-reservations.page.scss'],
})
export class MyReservationsPage implements OnInit {
  user: any;
  userId: string;

  constructor(
    private auth: AuthService,
    private router: Router,
    private afs: AngularFirestore
  ) {}

  ngOnInit() {
    this.auth.user$.subscribe((user) => {
      this.userId = user.userId;
    });
  }

  fetchBookings() {
    this.afs
      .collection('user')
      .doc(this.userId)
      .collection('BookingHistory')
      .get()
      .subscribe((querySnapshot) => {
        querySnapshot.forEach((doc) => {
          console.log(doc.id, ' => ', doc.data());
        });
      });
  }
}

HTML page

<ion-content>
    <ion-button (click)="fetchBookings()"></ion-button>
   
    <ion-item *ngFor="What I need to write here?">
        
      <ion-label>{{"What I need to write here?"}}</ion-label>
      
    </ion-item>
</ion-content>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First you'll need to store the data instead of the console.log() and you extract the data with the ngFor method.

<ion-content>
<ion-button (click)="fetchBookings()"></ion-button>

<ion-item *ngFor="let data of storedData">
  <ion-label>{{data.TimeSlot}}</ion-label>
  <ion-label>{{data.BookedAt}}</ion-label>
  <ion-label>{{data.BookingDate}}</ion-label>
  
</ion-item>
</ion-content>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!