I'm injecting NavController in my constructor as I want to push a page. But, below code doesn't work in Ionic 4. It was totally okay in Ionic 3.
Constructor
constructor(public menuCtrl: MenuController, public navCtrl: NavController) {
this.menuCtrl.enable(true);
}
Method
goToSecondPage()
{
this.navCtrl.push(list);
}
IONIC 4 - Angular (ionic start appName --type=angular)
Physical Back Button and Back Button Menu
In the Target page (second page), do:
SecondPage TS
SecondPage HTML
_
P.S.:
May be necessary for menu links in HTML:
Like in "app.component.html" on projects sidemenu
See More:https://beta.ionicframework.com/docs/api/buttons/
NavController as this is deprecated in IONIC 4.
Structure is like this.
You can use parameters if you want to pass it.
this.router.navigate('/pages, { locs: this.locId }])');
Example: With Pages directory.
Example: Without Pages directory and parameters.
This link is useful for the tabs. For more Info go through this link. [https://medium.com/modus-create-front-end-development/upgrading-an-ionic-3-application-to-ionic-4-eaf81a53cdea][1]
Now, to complete the final step and implement those routes in our app-routing.module.ts file, they would look like this:
setRoot in html page
or in class
Push
or
Pop
or
you can also navigate backwards programatically:
p/s: https://www.joshmorony.com/converting-ionic-3-push-pop-navigation-to-angular-routing-in-ionic-4/
first import navcontroller import { NavController, AlertController } from '@ionic/angular'; and now go forward also dont support it was best in ionic 3 this.nav.navigateForward('/ChatPage') supported in ionic 4 for but my sugesstion one should use angular routing
for more info click here
It doesn't work in Ionic 4. Ionic 4 is based on Angular Routing. So, just use the following code, and write a route for this.
Paste following code in
<ion-toolbar> </ion-toolbar>
for back button in the 2nd page.