cannot set root page dynamically so that back button can be routed back to unwanted pages.
to Set root page dynamically like in ionic-3 setroot()
this.app.getRootNav().setRoot(DrivernumberComponent);
this.navCtrl.push('FilmDetailsPage');
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 simply transition between routes and the framework does the rest of the work.
this.navCtrl.navigateRoot('/DrivernumberComponent');
In your case you need to redirect route to your root that you want to move i.e. "DrivernumberComponent"
Related
I am going to build flutter app with Getx.
I followed nested navigator from
https://github.com/jonataslaw/getx/issues/799#issuecomment-730719165
at this example, only shows 1 step sub routes like "/browse".
I need to make another sub routes like "/browse/tabX" and "/browse/tabY"
when click browse button from BottomNavigationBar, It shows tabs (tabX and tabY) on the top. and tabX is default selected.
for the body, it shows automatically their pages.
Also using Get.Named('/browse/tabY') can access to open their page(select second tab and show their body).
Can you help me?
Oh Now I got the answer!
What I make a mistake is I did not use "sub-name".
for example, at initialRoute,
I used '/home/browser' but it should be '/browser' if it is sub-route.
Because the concept is route to subrouter's root and handle by subrouter.
so "initialRoute from root" route to /home first.
and "initialRoute from subroute" route to /browser again!
I use classed variable instead just string so I did not figure this difference out.
I'm developing a flutter application where if the user is logged in, he'll see a page with 5 different pages (using Page Controller). I'm trying to use flutter navigator to kind of develop the navigation for the app. This is what I'm trying to achieve: Let's say there are 5 pages on the landing page: a-page, b-page ,c-page, d-page, e-page. The user initially lands on the c-page, at this point, the path should be "/c-page" and whenever the user switches the page, the path should change accordingly. For instance, currently the path is "/c-page", if the user switches to the b-page, the path should be "b-page". So basically the b-page path should replace the c-page path in this case. I tried replacing the path but wasn't completely successful. How can I achieve this?
Thank you in advance.
I have a questionnaire App with more than three pages .. I use NavCtrl to go to next page >> but when I go back using back to the previous page using NavCtrl the page displays all forms blank and the data is lost.
Please Help Me :(
There are multiple ways to implement that. Full documentation: https://ionicframework.com/docs/api/navigation/NavController/
Using navCtrl.push(page) to navigate is one option. In that case you have a root page, that is set up in your app.component.ts.
When you return from pushed page by using the back button or closing the view, the root page should be the same.
Note: You need to differentiate between root pages and push pages. The root page is your active page, when you then push pages, the root pages does not change. But when you change the root page, by using setRoot, Lifecycle Events, constructor, ... are called.
For example, I have a page in my application called page2 that I want to access like mysite.com/page2
in the application.ini file I would have a section for it
resources.router.routes.index.route = '/page2/'
resources.router.routes.index.defaults.controller = index
resources.router.routes.index.defaults.action = page2
My question is, what if I have several pages that I want to access as children of the index controller. There must be a method that doesn't involve creating a new section in application.ini every time I have a new page...
Any advice?
This StaticRoute plugin by Ekerete Akpan uses reflection to inspect your default controller and add static routes of the form /actionname for all action methods it finds there.
This means that you don't have to add an explicit route for each of those actions. Just add an action to the default controller and the corresponding view-script in the expected place. No need to change any routing files or application.ini just to add a new top-level url.
Note, however, that since the plugin uses Reflection to inspect your default controller, using it has performance implications.
In my master page I have a placeholder where a Html.RenderPartial() will render a collection of (bread)crumbs which are effectively a list of links I build up using action, controller names and RouteValueDictionary's.
I have an action that is called from multiple places to view a short-list and so when building the list of breadcrumbs for this actions view to display. Ideally I'd like to use Request.UrlReferer as the penultimate crumb.
Before unconditionally using this URL I want to check that it will actually match at least 1 route so I can be sure if the user clicks it they will get a view from my app and if they don't I will simply use the home page instead.
Any suggestions how I would go about this?
Take a look at this post http://haacked.com/archive/2007/12/17/testing-routes-in-asp.net-mvc.aspx