Wait until logout is done

Controller in my default route gets executed after I logout. For loginG out I am just calling a server route using $http.post. As the thing is async, execution continues to go to my default route '\' but I don't want controller of my default route to execute until logout is complete. How can I create a link between logout and my controller? I know I can use promise to wait for Logout but this would be only in the function where I am calling logout. How can I wait in my controller for logout to finish?

Will appreciate any help. Thanks.

Answers


Promises let you add a handler to their completion that's chainable:

// inside your controller action causing the log out:

$http.post("/logout").done(function(result){
   // here you're logged out, the promise has its value
   $location.href = "/"; // change route
});

Note: you can also wait in your router, but I assume from your question you'd like to avoid that.

Note2: I'd extract membership into a service.


Need Your Help

Does ebay API allows to create a listing draft?

ebay-api

I would like to create a listing ebay draft as it is possible to do manually using this flow:

How to make spidev.c work on samsung s5p6818/Android5.1

android linux-kernel linux-device-driver embedded-linux bsd

I'am using a develop board of samsung s5p6818 soc. After choosing "user mode spi""SLSI SPI port0" on menuconfig, and adding these code in plat-s5p6818/drone/device.c,