我注意到,当我通过一个参数是一个数组$ location.search(),它是连接codeD如下面的例子
I notice that when I passed a parameter that is an array to $location.search(), it was encoded as in the following example
$ location.path('/ somePath')搜索('的ID [] ='[1,2,3]);
$location.path('/somePath').search('ids[]=', [1, 2, 3]);
变为
/ somePath DS%5B%5D = 1和; DS%5B%5D = 2及DS%5B%5D = 3
/somePath?ds%5B%5D=1&ds%5B%5D=2&ds%5B%5D=3
有没有办法避免URL编码?
Is there a way to avoid the url encoding?
对不起已故的答复,但我打一个类似predicament自己,以为我提供建议。
Excuse the late reply, but I struck a similar predicament myself and thought I'd offer advice.
在总之,如果你打算使用 $ location.search
你无法避免的URL为EN codeD。
In short, if you intend on using $location.search
you cannot avoid the URL being encoded.
如果你看看在折角源, location.js
具体而言,你会发现,在函数返回组成的网址(即 LocationHtml5Url
)的所有依靠另一个名为函数调用 toKeyValue
,它将连接code每当他们设置的所有键 - 值对。
If you take a look at the Angular source, location.js
specifically, you'll notice that the functions return composed URLs (i.e. LocationHtml5Url
) all rely on another function call named toKeyValue
, which will encode all key-value pairs whenever they are set.
此外,在本例中使用的情况下,您所提供的,你不需要你的钥匙里的平等。当 $ location.search
被称为有两个参数,它们被视为由角一个键值对。
Furthermore, in the example use case you've provided, you don't need the equals inside your key. When $location.search
is called with two parameters, they are treated as a key-value pair by Angular.
如果您需要使用的位置的URL就已经连接codeD之后,你可以随时调用 德codeURIComponent
。
If you need to make use of the location URL after it has been encoded, you could always call decodeURIComponent
.