Passing page object as this to other pages & providers


#1

Hi,

I am novice to Ionic 2. I was searching for something and came across this suggestion in stack overflow

you could pass the parent page along with the nav push. that way you could accces the parent page as a navParamter.
parent page:
goToChildPage() {
this.navCtrl.push(ChildPage, { “parentPage”: this });
}
childpage:
this.navParams.get(“parentPage”).someFnToUpdateParent();

I tried this; I am able pass page object as 'this" to all immediately pushed pages popups & providers and I was able to execute the call backs in parent page successfully.

My question here is; is this valid or erroneous approach?


#2

I don’t know about “valid”, but I think it’s a bad idea, because it encourages overly tight coupling between pages. I prefer using shared services and observables to transfer information between pages over directly calling methods of component B from component A.