Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Get object array data inside a document in Firebase

$
0
0

@RsUnsainted wrote:

I’ll try to explain this as clear as possible, since English is no my main language: I’m trying to get this object data, which is stored in a field called ‘orders’ inside a user document, basically every order I make through the shopping cart, it creates a new order inside the user document as I’ll show you in the next img.


As can be see from the image the field orders has the following fields: cart which is an object array and Where I want to get that data from!, pickuptime, location and total, those 3 last fields, I have no problem in getting the data.

I can access pickuptime, location and total fields since they aren’t inside the cart object using the following code:

constructor(private aF: AngularFirestore, private aS: AuthService) {
const ordenes = aF.doc(users/${this.aS.getInfo()});
this.userOrders = ordenes.valueChanges();
}

getInfo() method just gets the current user uid.

Now when I try to display the data obtained from the document I just get to display the fields that are out of the cart object array.

This is my code to display data:

<ion-list>
    <ion-card *ngFor="let p of ((userOrders | async)?.ordenes)">
        <ion-card-header>
            <ion-card-title>{{ p.name }}</ion-card-title>
        </ion-card-header>
        <ion-card-content>
            <img src={{p.img}}>
            <br>
            <ion-card-subtitle>{{p.desc}}</ion-card-subtitle>
            <ion-row class="ion-align-items-center">
                <ion-col size="4">
                    <ion-label color="secondary">
                        <b>Total: {{ p.total}}</b>
                    </ion-label>
                </ion-col>
                <ion-col size="8" class="ion-text-right">
                    <b>Recoger en sucursal: {{p.sucursal}}</b>
                </ion-col>
            </ion-row>
            <ion-row>
                <ion-col>
                    <b>Hora: {{p.horarecoger}}</b>
                </ion-col>
            </ion-row>
        </ion-card-content>
    </ion-card>
</ion-list>

Any Help would be really aprecciated!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>