问题描述
我在确认 Ionic 3
application
的待付款时遇到问题.
每当我按下按钮 "Paid",
它都会产生这个 error
, "Reference.push failed:
第一个参数包含未定义的属性'confirm.orderTotal'..."
如果我点击 按钮,我的意图是把我的待处理订单带到 Firebase 中的确认
代码>table
.
谁能帮我解决这个错误?谢谢!
我的打字稿编码
导出类 CashierconfirmPage {导航:任何;ConfirmItem = {} 作为 orderItem;confirmItemRef$: FirebaseListObservable<orderItem[]>orderItemRef$: FirebaseListObservable<any>构造函数(公共cart_data:CartData,公共navCtrl:NavController,公共导航参数:导航参数,私有数据库: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,订单号:this.confirmItem.orderNumber});}}
我的 HTML
<ion-navbar><ion-title>待付款订单</ion-title></离子导航栏>
<h2>订购商品:</h2><li><ul *ngFor="let ordermenu of item.Ordermenu">{{ordermenu.itemName}}</ul></li>
<input type="text" ngDefaultControl [(ngModel)]="confirmItem.orderNumber" placeholder="{{item.orderNumber}}"></div>
<input type="text" ngDefaultControl [(ngModel)]="confirmItem.orderTotal" placeholder="{{item.orderTotal}}"></div><button(click)="addConfirmItem(confirmItem)" ion-button清除小图标-right color="dark">有薪酬的</按钮></离子项目>
您好,我的英语可能不正确,我来自巴西,正在使用谷歌翻译,抱歉."
关于你的问题,我也遇到了同样的问题,我能够解决它.Firebase 不接受 undefined 和 yes null 作为空形式.您应该添加|| null".
例如:
addConfirmItem(confirmItem: orderItem){this.confirmItemRef$.push({//Ordermenu: this.cart_data.getCart(),orderTotal: this.confirmItem.orderTotal ||空值,orderNumber: this.confirmItem.orderNumber ||空值});}
我希望我已经帮助并且也帮助了遇到同样问题的其他人.拥抱!
I am having problems with confirming the pending payment of my Ionic 3
application
.
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!
My typescript coding
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
});
}
}
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>
"Hello, my English may not be correct, I'm from Brazil and I'm using Goolgle translator, sorry."
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"中包含未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!