This is my page ts code where i am going to pass the data to another page
import { Component, OnInit } from '@angular/core';
import { NavigationExtras, Router } from '@angular/router';
export class CompListPage implements OnInit {
opencomp(complaint) {
let comptype = complaint.comp_type;
let navigationExtras: NavigationExtras = {
state: { data: complaint, comptype },
};
this.router.navigate(['comp-detail'], navigationExtras);
}
}
This is my ts code where i am receiving data
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
export class CompDetailPage implements OnInit {
constructor(
private router: Router,
private activateroute: ActivatedRoute )
{
this.activateroute.queryParams.subscribe((params) => {
this.complaintdata = this.router.getCurrentNavigation().extras.state.data;
console.log(this.complaintdata);
});
}
}
Can anyone help me to save the passed data in my current page