Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Created March 17, 2017 14:59
Show Gist options
  • Save annibuliful/a86e249a3f1128ada529cc6fd4e9c4e8 to your computer and use it in GitHub Desktop.
Save annibuliful/a86e249a3f1128ada529cc6fd4e9c4e8 to your computer and use it in GitHub Desktop.
// เรียกใช้ตอนคลิก
buy() {
let UserId = 'test';
let Queue = this.list.buy(UserId, this.UserProduct);
Queue.subscribe(data=> {
this.Queue = data;
});
console.log(this.Queue)
}
// service
buy(UserId: string, ProductId: any[]) {
let queue = this.af.database.list(`Order`, {
query: {
orderByChild: 'MerchantId',
equalTo: ProductId[0].MerchantId
}
});
return queue.map(data => data);
}
function 2 ตัวนี้อยู่คนละไฟล์นะครับ
@ball6847
Copy link

เพราะว่าในช่วงเวลาที่รัน console.log(this.Queue) data มันยังมาไม่ถึงเราครับ (async) ค่ามันเลยเป็น undefined

@ball6847
Copy link

ลอง {{ Queue | json }} ใน template ดูครับ มีจะมีค่าออกมาเมื่อค่าจาก firebase มาถึงแล้ว (อันนี้ผมมโนเอาว่า buy() เขียนอยู่ใน component นะครับ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment