i need some help explaining how to pass the data to a view because in my case i am sending a data to the a view and this data is well received but not showing to the landing page, I checked this with the console.log (the data leaves with this.navCtrl.navigateforward (['post', {data: data}])
CodePudding user response:
here's an example:
export class FirstPage implements OnInit {
constructor (private nav: NavController) {}
private showDetail (_event, item) {
this.nav.navigateForward(`url/${item.uid}`, { state: { item } })
}
}
and to get data on the second page you can use Router
like this:
export class SecondPage implements OnInit {
item: any
constructor (private route: ActivatedRoute, private router: Router) {
this.route.queryParams.subscribe(_p => {
const navParams = this.router.getCurrentNavigation().extras.state
if (navParams) this.item = navParams.item
})
}
}