Nicolas Cadilhac
Nicolas Cadilhac

Reputation: 4745

Angularjs: Issue when a query string is used on url without trailing slash

Using Angular 1.5 in an asp.net mvc site.

I have a base tag:

<base href="/fr/">

and html5mode is set.

The site works perfectly. I use ui-router... no issues. But today I hit one and this is when I try to browse to this kind of url:

http://example.com/fr?arg=1

I get an error from angular:

url is undefined

If I navigate to /fr/?arg=1 (with the trailing slash) the error goes away.
If I navigate to /fr/about/?arg=1, it will navigate to the index page but won't trigger the "about" state.

How to get the query string to work?

Update: setting strictMode to false, as @miqid proposed, fixed the issue for this url /fr/about/?arg=1 but not for the base /fr?arg=1

Upvotes: 2

Views: 617

Answers (1)

Nicolas Cadilhac
Nicolas Cadilhac

Reputation: 4745

End of the story is that the angularjs team won't change the current code to handle this scenario. They prefer to rely on the web server url rewriting capabilities (to add the missing trailing slash before the query string). Their doc is updated accordingly.

Reference

Upvotes: 0

Related Questions