I am actually developing a shopping app using Ionic framework and it needs to be restarted when a subscription is made by user. There is a callback for this and this is what I am doing for now:
$scope.onOpSuccess = function(state_param){
window.location.reload();
};
However it doesn't completely restart app but refreshes only current page. For example, in desktop environment, it currently indicates and keeps refreshing URL of
http://localhost:8100/#/app/subscription/thankyou
But I just need to start from
http://localhost:8100 (which will redirect to http://localhost:8100/#/app)
and get all the document and window variables cleared.
Of course I do not prefer the method of resetting current URL by using window.location.href = "http://localhost:8100"
because this should work in both iOS / Android as well as Windows Phones...not only on desktop browsers. Obviously, this is not the recommended way.
Is there any elegant and smart way for this? Only one or two lines of javascript code is preferred.
Please try this.
location.href = location.origin;
where location.origin stores root URL of your current webpage. (http://localhost:8100 in your case)
This will let your browsers to refresh page with origin URL.