passing data between pages ionic code example
Example 1: passing data from one page to another in ionic 4
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-details',
templateUrl: './details.page.html',
styleUrls: ['./details.page.scss'],
})
export class DetailsPage implements OnInit {
data: any;
constructor(private route: ActivatedRoute, private router: Router) {
this.route.queryParams.subscribe(params => {
if (params && params.special) {
this.data = JSON.parse(params.special);
}
});
}
}
Example 2: passing data from one page to another in ionic 4
ionic g service services/data
ionic g service resolver/dataResolver