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}])
Asked
Active
Viewed 1,092 times
-1
-
Please check this link "https://stackoverflow.com/questions/65607106/pass-the-data-between-pages-in-ionic-5/65611575#65611575" – Ravi Ashara Nov 01 '21 at 05:38
-
Please provide enough code so others can better understand or reproduce the problem. – Community Nov 01 '21 at 08:35
-
use angular router params. – Najam Us Saqib Nov 01 '21 at 14:09
1 Answers
1
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
})
}
}

Louay Sleman
- 1,794
- 2
- 15
- 39