Retrieve single value from firebase Realtime database with Key and services

Submitted 3 years, 1 month ago
Ticket #433
Views 766
Language/Framework Other
Priority Medium
Status In-Progress

I am simply clueless cause I am new to this language. I want to create a detail page where I have passed Key and get a single value from firebase. So here is my Productservice.ts.

import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList, AngularFireObject } from '@angular/fire/database';
import { Product } from './Product';

  providedIn: 'root'
export class ProductService {
  productListRef: AngularFireList<any>;
  productRef: AngularFireObject<any>;

  constructor( private db: AngularFireDatabase) { }

    return this.productListRef.push({,

  //get single
  getProduct(id: string){
    this.productRef=this.db.object('/product/' + id);
    return this.productRef;

    this.productListRef = this.db.list('product');
    return this.productListRef;

    return this.productRef.update({,

    this.productRef = this.db.object('/product/' + id);


Here is the product page where I have created a button to navigate to a product detail page and send a key with it. so that I can display its value in that page.

  <ngx-datatable-column name="Name"></ngx-datatable-column>
  <ngx-datatable-column name="Price"></ngx-datatable-column>
  <ngx-datatable-column name="Actions" prop="name">
    <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-value="value" let-row="row" >
      <div class="item-note" item end>
        <button ion-button clear [routerLink]="['/product-detail/',row.$key]">
          <ion-icon name="newspaper" style="zoom:2.0"></ion-icon>
        <button ion-button clear [routerLink]="['/product-edit/', row.$key]">
          <ion-icon name="create" style="zoom:2.0"></ion-icon>
        <button ion-button clear (click)="deleteProduct(row.$key)">
          <ion-icon name="trash" style="zoom:2.0"></ion-icon>

      <!-- <ion-button slot="end" color="warning" name="detail" (click)="getById(row)" >Detail</ion-button> -->

Submitted on Jun 03, 21

Currently we are not supporting this framework/language. Lets wait for other developers can help you on this. - Vengat 3 years, 1 month ago
add a comment

Latest Blogs