Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Add parameter to $routeUpdate to indicate the URL change is triggered programatically #14553

Open
@buremba

Description

@buremba

Do you want to request a feature or report a bug?
Feature.

When html5Mode is active and reloadOnSearch parameter is false, Angular fires $routeUpdate event when the URL is changed either by user via back/forward button of the browser or programmatically via $location.search. Currently, Angular doesn't send any parameter to $routeUpdate to indicate either the change is triggered by user action or programmatically.

I think we should add an extra parameter to $routeUpdate to indicate this information so that developers can reload the route if the URL change is triggered by user action.

When user changes the url via back / forward button of their browser, the state in controller must change. However if reloadOnSearch is false, back/forward button doesn't work because URL change doesn't cause controller to reload. The only way to get notified when user presses the back button is using $routeUpdate event; however currently it's not possible to find out if the change is triggered by user action.

$scope.$on('$routeUpdate', function() {
            if (routeChangeTriggerredByUser) {
                $route.reload();
            }
});

Related Stackoverflow questions:
http://stackoverflow.com/questions/31084176/why-does-angular-ui-router-reloads-the-page-even-when-reloadonsearch-is-false-in
http://stackoverflow.com/questions/23239683/browsers-back-button-doesnt-work-when-reloadonsearch-is-false-in-angularjs
http://stackoverflow.com/questions/18970727/back-button-when-reloadonsearchfalse

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions