Override back button to go to specific state using Angular UI Router

Viewed 1555

I have an Angular app with various different states defined. I do not want the user to be able to go back to previous states using the back button, as they are part of a simulation and it disturbs the simulation flow.

Is there a way I can override the browser back button to take users to the starting state of the simulation?

angular.module('participant').config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('simulations', {
            url: '/',
            controller: 'SimulationIndexController',
            templateUrl: '/angular_templates/simulations/index.html',
        })
        .state('simulation.content', {
            // other routes
        });

I want to go to the 'simulations' state when the user presses the back button on the browser but I am not sure how to accomplish this.

2 Answers
Related