Displaying data on a webpage using interpolation in HTML

I'm struggling to display user information on my HTML template. I can't seem to figure out what I'm doing wrong. Essentially, I want to retrieve values from the database and dynamically insert them into the main page for display. My issue lies with using ngFor; I'm not sure where to properly apply this tag in my scenario. The following is an excerpt from my HTML:

<ion-header>
    <ion-navbar>
        <ion-title>CONSULTATION DETAILS</ion-title>
        <ion-buttons start>
            <button ion-button (click)="dismiss()">
                <span class="txt">Close</span>
                <ion-icon ios="ios-close" md="md-close"></ion-icon>
            </button>
        </ion-buttons>
    </ion-navbar>
</ion-header>

<ion-content padding>
    <div padding-top class="card" *ngFor="let data of dataJSON">
        <div class="code">
            Consultation Confirmation Code: <strong>99887</strong>
        </div>
        <ul>
            <li class="category">
                <h2>Cardiology Consultation - General</h2>
                <span>{{data?.agendaTeste?.Document?.Specialty}}</span>
            </li>
            <li class="date">
                Scheduled for <span>05/09/2018</span> at <span>14:30</span>
            </li>
            <li class="doctor">
                <span>Attending Physician:</span>
                <strong>Dr. José M. - CRM-SP 0000/000</strong>
            </li>
            <li class="clinic">
                <strong class="label">Location of Consultation:</strong>
                <div>
                    <strong>Facility:</strong> SIMUS<br>
                    <strong>Address:</strong> Alameda dos Lírios, 327
                </div>
            </li>
        </ul>
        <div class="cta">
            <button class="btn btn-danger btn-block btn-rounded">
                Cancel Consultation
            </button>
            <small>If unable to attend, please cancel or reschedule your appointment.</small>

            <button class="btn btn-outline-midblue btn-block btn-rounded">
                Reschedule Consultation
            </button>
        </div>
    </div>
</ion-content>

This represents my code structure.

constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
    var query = firebase.firestore().collection("agendaTeste")
    var auxint = 0;
    this.dataAux
    let auxString = '[';
    query.where('Document.Patient', '==', this.patient).get().then(res => {
        res.forEach(item => {
            if (item.exists) {
                auxint++;
                auxString += '{"id":"' + item.id + '","agendaTest":' + JSON.stringify(item.data()) + '}';
                this.showTime = item.get("Document.Time");
                console.log(this.showTime);
                this.test = this.computeDate(this.showTime);
                this.doctorId = item.get("Document.Doctor");
                this.specialty = item.get("Document.Specialty");
                this.facility = item.get("Document.Facility");
                console.log(this.doctorId);
                console.log(this.specialty);                    
                console.log(this.test);
                console.log(this.facility);

            }
            if (res.size != auxint)
                auxString += ', ';
        })
        auxString += ']';
        this.dataJSON = JSON.parse(auxString);
    }).catch(err => {
        console.log('An error occurred ' + err);
    });

}

Despite logging the information correctly in the console, when attempting to render it as shown above, I end up with a blank page. It seems like there might be an issue with how I'm utilizing ngFor.

Answer №1

<ion-content padding>
    <div padding-top class="card">
        <div class="codigo">
            Código de confirmação da compra: <strong>55678</strong>
        </div>
        <ul *ngFor="let item of itemList">
            <li class="produto">
                <h2>Smartphone - Modelo X123</h2>
                <span>{{item?.detalhes?.marca}}</span>
            </li>
            <li class="data">
                Comprado em <span>12/10/2021</span> às <span>09:45</span>
            </li>
            <li class="preco">
                <span>Valor:</span>
                <strong>R$ 1.299,00</strong>
            </li>
            <li class="entrega">
                <strong class="label">Local de entrega:</strong>
                <div>
                    <strong>Endereço:</strong> Rua das Flores, 123
                </div>
            </li>
        </ul>
        <div class="cta">
            <button class="btn btn-warning btn-block btn-rounded">
                Cancelar pedido
            </button>
            <small>Em caso de desistência, cancele seu pedido.</small>

            <button class="btn btn-outline-darkblue btn-block btn-rounded">
                Reagendar entrega
            </button>
        </div>
    </div>
</ion-content>

Since implementing the *ngFor directive within the ul tag, my issue has been resolved.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Detecting changes in Angular custom form controls when using `mat-select` with the `selectionChange` event

I'm facing an issue with my custom form control that includes a mat-select element I've been attempting to listen for the change event in the parent component However, my onTouchedCallback doesn't seem to be functioning for some reason Wh ...

Why is it that I have intellisense enabled for .js files but not for .ts files?

Below is the content of my package.json: { "name": "edge-node-api", "version": "1.0.0", "description": "Web API for Edge Electrons customers", "main": "api.js", "scripts": { "test": "echo \"Error: no test specified\" &am ...

Exploring the d3 chord diagram in Angular 2

Exploring ways to implement a chord diagram with Angular2 led me to discover that the d3.js library is capable of creating such diagrams. However, I am open to suggestions for other libraries that can achieve this as well :) I have successfully integrated ...

Angular 4: Automatically dismiss modal once form submission process is complete

My Bootstrap 4 modal closes properly when I press the close button. However, I want the modal to close after submitting the create button in the form. I am using Angular 4. <div class="modal fade" id="createLabel" tabindex="-1" role="dialog" aria-label ...

The utilization of ~ (tilde) for SCSS file imports seems to be malfunctioning in Angular 6

Having some issues with importing SCSS files in Angular6, need clarification on a couple of things: If I import my partials once in the global src/sass/styles.scss, do I still need to import them individually in all component.scss files? Is there a way t ...

Angular 15 experiences trouble with child components sending strings to parent components

I am facing a challenge with my child component (filters.component.ts) as I attempt to emit a string to the parent component. Previously, I successfully achieved this with another component, but Angular seems to be hesitant when implementing an *ngFor loop ...

What is the correct method for decoding a byte array sent from C++14 and received by PySerial in Python 3.8.10?

Sending JSON Strings from a Windows7 machine to an ODroid M1 running Ubuntu20.04 GNOME Desktop. The client is on Windows7, while the board receiving communications is an ODroid M1 running Ubuntu20.04. My C++14 application on Windows sends a byte array pe ...

Configurations for Django REST API to accept images sent from an Android device

Greetings! I am a newcomer to Django and currently utilizing it to build a web service. My goal is to establish a connection between Android and Django in order to upload an image from Android to a Django ImageField. I have implemented a serializer to stor ...

Tips for showcasing with [displayWith] in Material2's AutoComplete feature

My API returns an array and I am using Material2#AutoComplete to filter it. While it is working, I am facing an issue where I need to display a different property instead of the currently binded value in the option element. I understand that I need to uti ...

Is it feasible to utilize a single parent component with multiple unique child components in Angular 2?

Is it possible to create a parent component without specifying the child component? Typically, I would define a parent component and include the selector of the child component in the HTML file parent-component-1.html: //some logic <child-component-1 ...

"Generate a JSON file that includes the names of different locations along with

I am working with the following data: pt-PT:[Lisbon, Portugal][38.7138, 9.1394]; en-GB:[London, United Kingdom][51.5072,0.1275] For each culture, such as pt-PT and en-GB, I need to specify a location along with its coordinates. Can you provide me with ...

Facing compilation issues when using Typescript with Svelte

My project was set up using npm create svelte@latest, with ts enabled and tailwind added. However, when declaring <script lang="ts">, I encountered an Unexpected Token error, like the one below: D:/gits/rpg-board/src/lib/components/FilterB ...

Tips for including and excluding personalized Chips from input

Just started learning React/typescript, any assistance would be greatly appreciated Custom Chip (CC.chip) is a specialized Chip UI component that can be utilized as demonstrated below. const [isOpen, setIsOpen] = useState(true); const onClose = Re ...

Can I prevent users from selecting Today and future dates in Angular with ngx-bootstrap datepicker?

https://i.sstatic.net/hXpjn.pngHi there, I'm new to Angular and could use some assistance. I tried using the following code snippet to disable today and future dates: <input class="form-control" placeholder="Datepi ...

Angular components are not properly adhering to the specified height and width dimensions for child elements

I seem to be having trouble applying height/width to a child component in angular. Can someone take a look and point out where I may have gone wrong? app.component.html <app-child [width]="10" [height]="10"></app-child> .child.ts import { C ...

Ideas for structuring the design of Angular 2 with a PHP backend

I'm facing a major project that has evolved significantly over time. I am considering transitioning from jQuery to Angular 2 in the frontend, not just refactoring (this is different from discussions of refactoring jQuery to Angular that have been wide ...

Retrieve a specific object from a JSON array nested within an array of objects, by utilizing a PHP script

There are two JSON files that contain JSON objects, with one of the files containing an array of objects within another array of objects. The first file is orders.json: { "orders": [ { "address": null, ...

Deploying Initial Node+Express+Angular Application in Production

Embarking on my first endeavor to develop a Node.js Express app with Angular 7 for deployment in production has me pondering the following: What is the recommended folder structure for this project? Should I maintain separate projects for Node and An ...

The TypeScript declarations for Forge Viewer do not include typings related to Profiles

I've been utilizing typescript definitions for Forge from the DefinitelyTyped repository: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/forge-viewer However, there seems to be a lack of typings, particularly those associated wi ...

When using node.js, the Ajax success function is not being executed

Why doesn't success respond? Here is the code I've used: Client-side code: function add(){ var values = formserial(addd); var tok = "abc", var url= 'http://localhost:8181/add'; $.ajax({ type: "POST", ...