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) ;
this.navCtrl.push(ListpgPage,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">
Sample
{{xvar.nm}}
</ion-item>
<ion-item>
second item
</ion-item>
</ion-list>
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