Reference.push失败:第一个参数在属性'confirm.orderTotal'中包含undefined [英] Reference.push failed: first argument contains undefined in property 'confirm.orderTotal'

查看:182
本文介绍了Reference.push失败:第一个参数在属性'confirm.orderTotal'中包含undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在确认Ionic 3 申请的待付款方面遇到了问题。

I am having problems with confirming the pending payment of my Ionic 3 application.

每当我按下按钮付费,它会产生此错误Reference.push失败:第一个参数包含未定义的属性'confirm.orderTotal'...如果我点击按钮,我的意图是将我的待处理订单带到我的Firebase中的确认

Whenever i push my button "Paid", it produce this error, "Reference.push failed: first argument contains undefined in property 'confirm.orderTotal'..." my intention is to bring my pending orders to the confirm table in my Firebase if I clicked on the button.

任何人都可以帮我解决这个错误吗?谢谢!

Can anyone help me with this error? Thanks!

我的Firebase数据

export class CashierconfirmPage {
  nav: any;

  confirmItem = {} as orderItem;
  confirmItemRef$: FirebaseListObservable<orderItem[]>

  orderItemRef$: FirebaseListObservable<any>

    constructor(public cart_data: CartData, public navCtrl: NavController, 
      public navParams: NavParams,
      private database: AngularFireDatabase,) {

      this.orderItemRef$ = this.database.list('pendingorders');

      this.confirmItemRef$ = this.database.list('confirm');
    }

    addConfirmItem(confirmItem: orderItem){

      this.confirmItemRef$.push({
        // Ordermenu: this.cart_data.getCart(),
        orderTotal: this.confirmItem.orderTotal,
        orderNumber: this.confirmItem.orderNumber
      }); 
          }

}



我的HTML



My HTML

<ion-navbar>
    <ion-title>Pending payment orders</ion-title>
</ion-navbar>


    <h2>Ordered Items:</h2>
    <li>
        <ul *ngFor="let ordermenu of item.Ordermenu">{{ordermenu.itemName}}</ul>
    </li>

    <div>
        <input type="text" ngDefaultControl [(ngModel)]="confirmItem.orderNumber" placeholder="{{item.orderNumber}}">
    </div>

    <div>
        <input type="text" ngDefaultControl [(ngModel)]="confirmItem.orderTotal" placeholder="{{item.orderTotal}}">
    </div>

    <button (click)="addConfirmItem(confirmItem)" ion-button clear small icon-right color="dark">
        Paid
    </button>

</ion-item>

推荐答案

您好,我的英语可能不正确,我来自巴西,我正在使用Goolgle翻译,抱歉。

"Hello, my English may not be correct, I'm from Brazil and I'm using Goolgle translator, sorry."

关于您的问题,我面对同样的事情,我能够解决它。
Firebase不接受undefined和yes null作为空表单。你应该添加|| null。

About your problem, I was facing the same, and I was able to solve it. The Firebase does not accept undefined and yes null as empty form. You should add "|| null".

Ex:

addConfirmItem(confirmItem: orderItem){
  this.confirmItemRef$.push({
    // Ordermenu: this.cart_data.getCart(),
    orderTotal: this.confirmItem.orderTotal || null,
    orderNumber: this.confirmItem.orderNumber || null
  }); 
}

我希望我能帮助并帮助其他遇到同样问题的人。
拥抱!

I hope I have helped and also help other people who go through this same problem. Hugs!

这篇关于Reference.push失败:第一个参数在属性'confirm.orderTotal'中包含undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆