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.

$location.path() in $routeChangeStart causes infinite loop #9665

Closed
@sylouuu

Description

@sylouuu

Hi,

I didn't have this issue with 1.2.26. Extract of my code:

app.run(['$rootScope', '$location', 'config', function ($rootScope, $location, config) {
    $rootScope.$on('$routeChangeStart', function (event, next, current) {
        // Maintenance mode
        if (config.project.maintenance === true) {
            event.preventDefault();

            // The redirect must be inside this method since angular 1.3.0
            $rootScope.$evalAsync(function () {
                $location.path('/maintenance');
            });
        }
    });
});

The /maintenance route has an empty controller. This code is causing an infinite loop, but not with 1.2.26. Got this error.

I understand why there is an infinite loop as I don't test the current route before redirecting. Why it worked before?

Is it a bug or something that I skipped from the changelog?

Bests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions