View child from Firebase on Ionic

1

Hello

I have a project on Ionic that I need to show some promotions, however I need to "update" them after the launched app. For this I am using Firebase!

I was able to display in the app what I need, however I need to filter the child.

This is the Data Service .ts

import { Injectable } from '@angular/core';
import { AngularFire, FirebaseObjectObservable, AngularFireAuth, FirebaseListObservable } from 'angularfire2';

@Injectable()
export class Databaseservice {

  constructor(private _af: AngularFire) {
  }

  public listProdutos(): FirebaseListObservable<any[]>{
    return this._af.database.list('/produtos/produto1');
  }
}

This is the Script page that will display the .ts products

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Databaseservice } from "../../providers/databaseservice";
import { FirebaseListObservable } from "angularfire2";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  produtos:FirebaseListObservable<any[]>

  constructor(public navCtrl: NavController, public db: Databaseservice) {
    this.produtos = this.db.listProdutos();
  }

}

This is the page

<ion-header>
  <ion-navbar>
    <ion-title>
      Teste
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>

  <h2 class="text" *ngFor="let item of produtos | async">
    {{item.$value}}
  </h2>

</ion-content>

This is the tree in Firebase

Andthisistheresultintheapp

I'dliketoknowhowdoIdisplaythechild"name" in a tag Example: {{name. $ Value}}

and display the child "price" in another tag Example: {price. $ Value}}

So that I can manipulate the location on the page (html) to be displayed. Thank you!

=

    
asked by anonymous 27.05.2017 / 01:11

1 answer

0

Where you have {{item. $ value}} exchange for {{item.name}} or {{item.preco}}

In this case, after the dot comes the name of the firebase field.

    
02.06.2017 / 17:54