Как я могу удалить все данные Firebase по нажатию кнопки в Ionic3? - PullRequest
1 голос
/ 27 марта 2019

Я хочу удалить все данные из firebase, нажав кнопку в моем приложении Ionic 3.

вот мой HTML-код и это показывает некоторую ошибку, которая говорит, что «не может прочитать ключ свойства»

  <ion-list *ngFor="let item of orderList$ | async">
        <ion-item>
          <ion-label text-wrap>
             <h2 style="font-weight: bold">{{item?.name}}</h2>     
             <p  style="color: black">Quantity :  {{item?.qty}}</p>    
             <p style="color: black">Price :  {{item?.price}}</p>
             <p class="pr" style="font-weight: bold; color: black">Total :</p><p class="pr" style="color: red"> {{item?.total}}</p>

            </ion-label>
        </ion-item>
        <ion-input type="hidden"  [(ngModel)]="placed.orders" [value]="namees">{{namees}}</ion-input>
      </ion-list>

      <p style="color: black;">Total Vat(12%) : {{vatTotal}}</p>
      <p style="color: black">Price Subtotal : {{priceTotal}}</p>
      <label style="font-weight: bold; font-size: 18px;">Order Total :</label>
      <ion-input type="number"  [(ngModel)]="placed.totalp" [value]="vatTotal + priceTotal" required="true" disabled="true" style="font-size: 18px;">{{vatTotal + priceTotal}}</ion-input>
      <button ion-button block clear (click)="addPlaced(placed)">Submit Order</button>
      <button ion-button block clear color="default" (click)="removeItem(item)">Delete Order</button>

это мой код ts, где инициируется removeItem

  removeItem(item: Item){
    this.dr.removeItem(item).then(()=>{
      this.toast.show(`${item.name} removed!`);
      this.navCtrl.setRoot(HomePage);
    });
  } 

сервис удаления элементов

private cartlistref = this.db.list<Item>('cart');

  removeItem(item: Item){
        return this.cartlistref.remove(item.key);
    } 

мой дополнительный вопрос: можно ли удалить созданный список БД "корзина" по нажатию кнопки?

...