In my web application, there are two pages with forms: purchase1
and purchase2
.
If a customer refreshes the purchase2
page, I want them to be redirected back to purchase1
.
I've been struggling to achieve this by configuring a setup like:
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.when('/purchase2', '/purchase1');
}
However, this approach prevents me from ever reaching the purchase2
page.
What I really need is for this redirection to occur only when a user manually refreshes the page.
Is there a way to accomplish this? Perhaps an Angular function that triggers on Refresh?
Something along the lines of:
$scope.onRefresh = function(){
$location.path('/dashboard/purchase1');
}
So far, I haven't come across anything like it.