如何传递包含相同RECEIPT_NUM
的多个对象并在下一页中检索对象?如果我的问题不好,我很抱歉。编码新手
示例JSON
putAwayPurchaseOrderListData=[
{
"Ob1":"35879",
"0b2":"791314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
},
{
"Ob1":"4995879",
"0b2":"191314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
},
{
"Ob1":"7995879",
"0b2":"0491314",
"RECEIPT_NUM":"1296",
"PO_TYPE":"STD PO"
}]
我的Html
<ion-card class="item-list-body" *ngFor="let putAwayPurchaseOrder of putAwayPurchaseOrderListData" (click)="goToPutAwayPurchaseOrderDetails(putAwayPurchaseOrder.RECEIPT_NUM,putAwayPurchaseOrderListData)"></ion-card>
发送的组件1
goToPutAwayPurchaseOrderDetails(RECEIPT_NUM,putAwayPurchaseOrderListData)// sending all objects here. With RECEIPT_NUM thinking to map the objects in next retrieving component
{
this.navCtrl.push(PutAwayPurchaseOrderListDetailsPage,{RECEIPT_NUM,putAwayPurchaseOrderListData});
}
组件2//需要检索包含被点击卡片RECIEPT_NUM
的所有对象
console.log(this.navParams.data)
当前o/p
[3396,{
"Ob1":"35879",
"0b2":"791314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
},
{
"Ob1":"4995879",
"0b2":"191314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
},
{
"Ob1":"7995879",
"0b2":"0491314",
"RECEIPT_NUM":"1296",
"PO_TYPE":"STD PO"
}]
预期结果只有以下对象包含相同的RECEIPT_NUM
对象:
{
"Ob1":"35879",
"0b2":"791314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
},
{
"Ob1":"4995879",
"0b2":"191314",
"RECEIPT_NUM":"3396",
"PO_TYPE":"STD PO"
}
您可以使用服务类。初始化其中的navCtrl。并将数据推送到服务类内的变量。该变量将在所有类中都可用。如何使用服务,在这里我将一个值从应用程序组件传递到兄弟组件