Description
Having 2 states defined as:
var state1 = { name: 'home', url: '/home?param1', controller: function() { }, templateUrl: 'home.html'}
var state2 = { name: 'home.foo', url: '/foo/:id', controller: function() { }, templateUrl: 'foo.html'}
When navigating to state2 (home.foo) with the parameters ({id: "idValue", param1: "param1Value"}
) I would expect the URL to look something like:
home/foo/idValue?param1=param1Value.
This is correct and true for 0.2.11, but since 0.2.12 there seems to be a bug with the format of the URL since the generated URL looks like this:
home/foo/param1Value?id=idValue
Which doesn't make any sense since id is not a query string parameter.
Looking at the code the change that seems to be introducing this error is in the function parameters() being called in UrlMatcher.prototype.format
at line 989 in 0.2.12 or at line 906 in 0.2.11.
0.2.11 calls the method objectKeys(this.params)
which returns the parameters in a different order than 0.2.12 method this.params.$$keys()
and that seems to be causing an error in the order the parameters get appended to the generated URL.
Plunkers reproducing the issue:
0.2.11: http://plnkr.co/edit/0L4cLM?p=preview
0.2.12: http://plnkr.co/edit/iVGuKU?p=preview