Home Ask Login Register

Developers Planet

Your answer is one click away!

uksz February 2016

Can I reload app without refreshing view?

I am using UI Router in my application, and I am wondering if I can reload - or destroy services when user is logging out, without refreshing the view? So far, when user is logging out, backend logs him out, and he is redirected to the login view. However, all of the services are still working. Any ideas?



ashfaq.p February 2016

UI Router provides with state transition events, so you can listen for the transition event, and when the transition happens to the login page, you can manually refresh your services. By refresh I mean you can bring them to initial state by initializing them to initial state.

You can keep a function like close() in your service which declares everything again. So you can call this function on logout to refresh your service.

refer this for example: Refresh factory/service instance

gr3g February 2016

//Controller where the logout button is called
.controller("ctrl", function(destroyService){

   this.logout = function(){
      //Probably an ajax request to logout from server.
      $http.post("logoutUrl", userId)


.service("destroyService", ["service1", "service2", function(service1, service2){

  this.destroyAll = function(){


Post Status

Asked in February 2016
Viewed 1,132 times
Voted 5
Answered 2 times


Leave an answer

Quote of the day: live life