multiple executions of page constructor using navParams

给你一囗甜甜゛ 提交于 2020-01-17 06:40:13

问题


I need to search customers and items from add-invoice page.For that I have created two separate pages call customer-search and item-search.When I search the customer I have to go to the customer-search page and come back to the add-invoice page with customer detail.After that in the same same way I have to go to the item-search page multiple times for get multiple items and come back to the add-invoice page with items details.

To do that task,I'm passing navParams from the two pages to add-invoice page.

set navParams in customer-search page

itemTapped($event, customer) {
  this.navCtrl.push(AddInvoicesPage, { customerData: customer });
}

set navParams in item-search page

itemTapped($event, item) {
  this.navCtrl.push(AddInvoicesPage, { itemData: item });
}

access to the navParams in add-invoice page

this.customer = this.navParams.get('customerData');
this.item = this.navParams.get('itemData');

When I'm accessing the data separately It works.But the problem is, when I'm accessing the itemData after accessing the customerData, customerData will become "undefined".In the same way itemData will become undefined, when I'm accessing customerData after accessing itemData.

I just need to access to both customerData,itemData in the same time.What is the most suitable way to overcome this problem! Give me the best suggestion.Thank you!

来源:https://stackoverflow.com/questions/44512464/multiple-executions-of-page-constructor-using-navparams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!