Getting array data from NavParams


Am struggling with a simple requirement, i.e. capturing an array data between 2 pages

In the Page1.ts I have

openDet( pData) {
console.log(pData) ;

The console .log does display the content of the array pData

Page1.ts:46 {nse: “DLF”, nm: “DLF Limited”, last: “200”, v1: “4%”, v2: “424”, …}
listpg.ts:25 in ngOnInit – Child Page

The child page is listpg

In the child page listpg.ts

export class ListpgPage {

pChildData: any;

constructor( private navParams: NavParams) {}

ngOnInit() {
this.pChildData = this.navParams.get(‘pData’);
console.log(“in ngOnInit – Child Page” ) ;

However if I try to print the value
console.log(pData); I get a error
core.js:1350 ERROR Error: Uncaught (in promise): ReferenceError: pData is not defined
ReferenceError: pData is not defined

In the 2nd page HTML

  <ion-item *ngFor="let xvar of pChildData">

    second item 

Here it is not able to get any data into xvar from pChildData

Basically I am struggling to capture the array data in the 2nd page, not sure what am I doing wrong. Or what is the right syntax .

Appreciate any pointers


can you format your code so we can easily understand !!!


Change to

this.navCtrl.push(ListpgPage, {pData: pData});


Thank you very much .
this worked.


I got the solution as provided by avishai .
Thanks for offering to help.