Skip to content

$locationProvider.html5mode, ui-sref with params and $stateParams bug #1143

@c0debreaker

Description

@c0debreaker

I just started using $locationProvider.html5Mode(true)

It's nice but I encountered one issue that I couldn't figure out how to make it work.

I wasn't using $locationProvider.html5Mode(true) before so line 4 on my gist below was not commented out. It was working great.
https://gist.github.com/c0debreaker/66273c92ed11623ad174

Now with $locationProvider.html5Mode(true), and line 4 commented out and my existing ui-sref code below,

<a ui-sref="main.monthlycassandra.daily({udi : monthlyData.udi})">{{monthlyData.udi}}</a>

it will not work anymore. The $stateParams object becomes empty. The link that is logged in my Chrome's Network tab is

http://localhost:4444/api/reports/daily?token=535c0d2a22135b2787876988

However, when line 4 on my gist is not commented, the link below is logged and it works

http://localhost:4444/api/reports/daily?token=535c0d2a22135b2787876988&udi=Targetdev5

However, the path is also displayed on the location bar on top of the browser which I don't want.

The difference is that &udi=Targetdev5 was missing.

I've tried different suggestions on few stackoverflow links I've found like the
<base href="/"> and also $locationProvider.html5Mode(true).hashPrefix('!') but it didn't fix the issue.

Any help would be greatly appreciated!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions