I have an issue with a SPA app written in angularJS. The application consist of thre views - login view, main view and log out view.
- myapp/#/login
- myapp/#/main
- myapp/#/logout
my route provider:
function Router($routeProvider) {
$routeProvider
.when('/login', {
templateUrl: 'app/components/login/login.tmpl.html',
controller: 'login.ctrl',
controllerAs: 'vm'
})
.when('/main', {
templateUrl: 'app/components/dashboard/main.tmpl.html',
controller: 'dashboard.ctrl',
controllerAs: 'vm'
})
.when('/logout', {
templateUrl: 'app/components/logout/logout.tmpl.html',
controller: 'logout.ctrl',
controllerAs: 'vm'
})
.otherwise({
redirectTo: '/login'
});
}
Use case: 1) user logs in. 2) user sees the content in the main view 3) user logs out. 4) user is redirected to the logout view for confirmation 5) user is redirected to the login view
If I press the back browser button after step 5 I am redirected to the main view. Is there a way to change the behavior of the back button when I am in the login view? I believe it is something simple and I apologize if the question is duplicated. Thank you for your time and responses!
$window.history.pushStatedeveloper.mozilla.org/en-US/docs/Web/Guide/API/DOM/…$locationProvider.html5Mode(true)in order to use$window.history.pushState