How to use navCtrl.parent in ionic4

I’m migrating source code from ionic3 to ionic4.
I don’t know how to migrate using the following code.

ionic3’s code

  1. this.navCtrl.parent.parent.push(DetailPage, {selectedPage: myPage});
  2. this.navCtrl.parent.select(0);

please tell me example above code for ionic4.

I’m not sure how to say this politely, especially since it’s your first post, and you should certainly feel free to hear what other people think, but I would describe this as “an opportunity to rethink the app structure, especially as it pertains to navigation”. Even with the old Ionic NavController, I have always thought it was a mistake for Ionic to expose parent, because it encourages people to spaghettify their code and blow up encapsulation.

Components should never depend on or even know anything about anything above them in the view hierarchy, because it makes them not truly independent. If the component really can’t be detached from its host, then it makes more sense to simply merge it into said host.

So as not to be completely negative, part 5 of the Tour of Heroes covers probably more than you need to know about the Angular router that you will be dealing with in v4 of the framework, and should help you as you rewrite things. One more thing: I would not pass objects like myPage through the router at all. I have had much more reliable results sticking strictly to scalars for router parameters.

Thank you for your reply.
You suggest changing the code structure.
But I’d like to use parent and nowhere is written how to use parent in ionic4.
Could you give me an example code for ionic4?