i am trying to get current page instance in app.component in ionic 4.
in ionic 3 i can do it like this
this.nav.getActive().instance
Ionic has a similar concept where you can only view the page on top of the navigation stack. If you want to navigate to another page, you need to do one of these two actions: Push: Push the page on the stack. It means putting the element at the top.
Navigation in Ionic works like a simple stack, where we push new pages onto the top of the stack, which takes us forwards in the app and shows a back button. To go backwards, we pop the top page off.
In Ionic 4 with Angular routing, there is no root page to be defined. Because Ionic 4 relies on Angular's router, the NavController has been changed to reflect this new reality, and for an Angular application there is no such a thing like "root" route.
You can access the url from the Router.
import { OnInit } from '@angular/core';
import { Router } from '@angular/router';
export class YourPage implements OnInit {
constructor(private router: Router) {}
ngOnInit() {
console.log('this.router.url', this.router.url);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With