Created
March 17, 2017 14:59
-
-
Save annibuliful/a86e249a3f1128ada529cc6fd4e9c4e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // เรียกใช้ตอนคลิก | |
| 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 ตัวนี้อยู่คนละไฟล์นะครับ |
ลอง {{ Queue | json }} ใน template ดูครับ มีจะมีค่าออกมาเมื่อค่าจาก firebase มาถึงแล้ว (อันนี้ผมมโนเอาว่า buy() เขียนอยู่ใน component นะครับ)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
เพราะว่าในช่วงเวลาที่รัน
console.log(this.Queue)data มันยังมาไม่ถึงเราครับ (async) ค่ามันเลยเป็น undefined