Как сопоставить данные в поле Firebase с чтением шестнадцатеричной строки из идентификатора тега nf c - PullRequest
0 голосов
/ 30 марта 2020

Я читаю идентификатор тега nf c и сохраняю его в базе данных в виде шестнадцатеричной строки. Это работает без проблем, но я хочу иметь возможность добавить продукт, содержащий соответствующий tagid, в мою корзину и не знаю, как go об этом.

Этот код позволяет читать тегид и сохранять в база огня:

readNFC() {
 this.nfc.addNdefListener(() => {
   this.presentAlert('ok');
 }, (err) => {
   this.presentAlert('ko' + err);
 }).subscribe((event) => {
   console.log(event);
   console.log(JSON.stringify(event));

   //this.presentAlert(this.nfc.bytesToHexString(event.tag.id));
   this.productForm.patchValue({ tagid: this.nfc.bytesToHexString(event.tag.id)});
 });
} ```

This is the code I'm using to then try get the product that contains the tagid that is read from the nfc tag but I'm having no success with it


```  private onNdefEvent(event) {
this.listenAlert.dismiss();

this.cartService.addProduct(this.product == 
 this.db.collection('products', ref => ref.where('tagid', '==', this.nfc.bytesToHexString(event.tag.id))));

}```

[image of firebase][1]


[1]: https://i.stack.imgur.com/NuRHt.png
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...