How to clear previous data when login (PROBLEM SOLVED)

Hi guys just want to know your insights about this issue cause I’m stuck finding the right solution.

I got all the right data from the server whenever i login. But when i started login again, It seems all the previous data wasn’t removed.

Are you referring to data that was stored in memory or local storage?

1 Like

I’m guessing that your referring to the data in the login form.
Just set the values to null, or empty string on login success.

I would also highly recommend using Angular-formly to handle your forms… makes life a lot easier in the long run.


If you’re referring to your scope data not beeing load with the new data,

i’ve ben using (on logout) :

$rootScope = $rootscope.$new(true); 
$scope = scope.$new(true);
1 Like

this is what I do

  1. After logout I send out an event.
  2. All the controllers / services listen on the event and will clear their data
1 Like

There is cache in ionic, and if you don’t clear scope, even if you have cleared data on services, you will see the same data.


thank to you sir! godbless

thanks to you sir! :smiley:

thanks for the idea sir. i managed to solved the problem!