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

Ionic 3 + Firebase - Display all child nodes

$
0
0

@Aurevoiiiir wrote:

Hi !

I’m starting to learn Ionic Framework with Firebase.
I have an a mobile app connected with Firebase.

Datas are organized like this :

I’d like to display on my app a list of all “nomCat”

Here is my code and I don’t know how to get all the “nomCat” List :confused:

/*Provider*/
import { Injectable } from '@angular/core';
import firebase from "firebase";

@Injectable()
export class MycartProvider {
  cart=[];
  firedata2 = firebase.database().ref('/shops');

  constructor() {
    console.log('Hello MycartProvider Provider');
  }

getCatdetails() {
        var promise = new Promise((resolve, reject) => {
            this.firedata2.child('/uidAuchan/uidCatFruits/').once('value', (snapshot) => {
                resolve(snapshot.val());
            }).catch((err) => {
                reject(err);
            })
        })
        return promise;
    }
}
import {Component, NgZone} from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { MycartProvider } from '../../providers/mycart/mycart';


@IonicPage()
@Component({
  selector: 'page-cart-list',
  templateUrl: 'cart-list.html',
})
export class CartListPage {


    displayCatName:string;


    constructor(public navCtrl: NavController, public navParams: NavParams, public cartProvider: MycartProvider,
              public zone: NgZone) {
    }
    loadCatdetails() {
        this.cartProvider.getCatdetails().then((res: any) => {
            this.displayCatName = res.nomCat;
        })
    }

ionViewWillEnter() {
        this.loadProddetails();
    }
}

With this code, I get CatName, but only for 1 Cat =>

Capture2

Thank you for reading, Can you help me please?

Posts: 4

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>