如何从Firebase页面上的ID获取数据

时间:2019-11-04 03:10:45

标签: angularjs firebase ionic-framework

我有一个firebase数据库,如下所示:

Table adress

我希望在我的页面单个地址上检索此JSON的信息,但是我不知道该怎么做,因为我是angular和firebase的新手。在我的不同代码下方

地址列表html

    <ion-card *ngFor="let item of items;" (click)="editItem(item.key)">
      <div><b>{{item.prenom}} {{item.nom}}</b></div>
    </ion-card>

地址列表.ts(方法)

 editItem(key){

    const UserId = firebase.auth().currentUser.uid;

    var usersRef = firebase.database().ref('adresse');
    var adaRef = usersRef.child(UserId);
    var adaFirstNameRef = adaRef.child(key);
    var path = adaFirstNameRef.toString();
    console.log(path);

    this.router.navigate(['single-adresse/' +key]);


  }

如何在唯一地址页上获取数据。如果您有我感兴趣的例子

多亏了孩子,我才能从firebase中恢复JSON链接。

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以像这样从Firebase获取数据

Ref:https://firebase.google.com/docs/database/web/read-and-write

SELECT
    STR_NAME ,
    CNT_ITEM as 'Code',
    TI_NAME as 'Item' ,
    UOM_CODE as UOM,

    sum(CNT_OPEN) as 'ActBeg',    In column i dont need to SUM it i need to get here the value for the first   of the selected date (in this case i need value for 2020-01-01) 
    sum(CNT_RCV )as 'Receiving',
    sum (CNT_TRIN) as 'TransIN',
    sum (ISNULL(CNT_DSD,0) + ISNULL(CNT_PROD,0)) AS 'PROD',
    sum(CNT_VOID ) as 'Void' ,
    sum (CNT_SOLD ) as 'Sales',
    sum (CNT_TROUT ) as 'TransOUT',
    Sum (CNT_CONS) AS 'BatchRMat',
    SUM (ISNULL(CNT_USAGE,0) + CNT_WASTE) as 'WASTE' ,
    sum (CNT_CLOSEC ) as 'TheoEnd' ,
    sum (CNT_CLOSE ) as 'ActEnd',
    sum ((ISNULL(CNT_OPEN,0) - ISNULL(CNT_OPENC,0)) + (ISNULL(CNT_CLOSE,0) - ISNULL(CNT_CLOSEC,0))) 
    AS 'VARIANCE',
    SUM ((ISNULL(CNT_OPEN,0) - ISNULL(CNT_OPENC,0)) + (ISNULL(CNT_CLOSE,0) - ISNULL(CNT_CLOSEC,0)) * 
   CNT_COST) as 'VCost',
    CNT_COST as 'Cost'
FROM
    CR_QC_COUNT LEFT JOIN
    CR_STORE ON STR_COMPANY = CNT_COMPANY AND STR_BRAND = CNT_BRAND AND STR_NO = CNT_STR_ID LEFT JOIN
    CR_QC_TRACK ON TI_COMPANY = CNT_COMPANY AND TI_BRAND = CNT_BRAND AND TI_ID = CNT_ITEM LEFT JOIN
    CR_QC_UOM ON UOM_COMPANY = CNT_COMPANY AND UOM_BRAND = CNT_BRAND AND UOM_ID = TI_PUOM
WHERE
     CNT_COMPANY = 1 AND CNT_BRAND = 1 AND CNT_DOB BETWEEN '2020-01-01' AND '2020-01-16' AND CNT_STR_ID IN (41)  and TI_NAME IS NOT NULL  and (CNT_SOLD !=0 or CNT_CONS!=0)
group by 
 STR_NAME,CNT_ITEM ,TI_NAME ,UOM_CODE,CNT_COST
order by 
 STR_NAME , CNT_ITEM