Ionic 3 - Lost form data when when I use pop function - ionic-framework

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.

Related

flutter- getx nested routes with tab

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.

How to use Navigator 2.0 with Page Controller in Flutter?

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.

Is there a function for set root in ionic 4?

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"

overriding setResponsePage() to build breadcrumb

I 'm trying to build my own simple breadcrumb component that pushes a PageRefence onto a List for each and every Link in the application.
Unfortunately, setResponsePage() is final (I use wicket 6).
The only other option that comes to my mind is to add a parameter to my base page constructor. But this would require me to change every link in the app..
Are there any other options?
Since you already have a base page, it's easier to override onBeforeRender() in your base page to update the breadcrumbs list that you'd store in your Session object.
Or am I missing something?
To answer my own question:
In the end I realized, that I do not want to have the breadcrumb updated on each new page.
Therefore I created an object that holds a List of Pagereferences. When I navigate to a new Page, I take the list of the current page, make a copy of it an add the current page. The resulting list is pased onto the new page.
All this is handeld in the base page.
Keeping it in the page, avoids problems with multiple tabs / windows.
Thanks for the help.

iPhone Objective-C: Best way to handle logout user A -> login user B?

I have an application that uses OAuth whose logic is something like this:
If there is a request token for the user that is valid stored, loads a UITabBarController with four views.
Else, brings the user to the login screen.
I realized today that if I am logged into my app, log out, and switch to another user, the data from the first user is displayed until I hit refresh. Also, the tab that was last viewed by the previous user is displayed (which is pretty strange for an application user's point of view).
I thought about removing the TabBarController and creating a new one, but I realized I was not sure how to do that, considering that I set everything up through Interface Builder. (Also, I'm not even sure if that is the best way.)
What is a good way for handling log out of A -> log into B? Also, if you need more information, I'll be very happy to elaborate.
Thank you!
I do it as follows
Login
Load and display the login screen
Load the root view controller in background
Insert the root view controller behind the login screen
Remove/release the login screen after successful login
Logout
Load the login screen and place it on bottom of the view stack (behind the root view)
Remove/release the root view controller (login becomes visible)
... start over at 2) in Login
If you store user specific data in the documents directory, store it in subdirectories
with the user name or id as directory name. One directory for each user.