MR.ABC
MR.ABC

Reputation: 4862

AngularJS Parameter in redirectTo escaped "?" breaks route

I simply like to redirect to an error page with a parameter. Its gets encoded to /error%3Ftype=404.
This breaks the routing. The route never get active. By typing or with location everything works like charm.

otherwise(
{
    redirectTo: "/error?type=404"
});

Upvotes: 0

Views: 199

Answers (2)

Prahlad Yeri
Prahlad Yeri

Reputation: 3653

You shouldn't manipulate the ? in the url yourself through routing. But rather, you can use the $location service in this manner:

$location.path('/error').search('type', 404)

Refer to this question for more details: how to pass "question mark" in url javascript

Upvotes: 2

MR.ABC
MR.ABC

Reputation: 4862

otherwise(
{
    template: " ",
    controller: function($location, $window) {
        $window.location = "/error?type=404";
        return false;
    }
});

Upvotes: 0

Related Questions