角资源URL编码 [英] Angular Resource Encoding URL

查看:127
本文介绍了角资源URL编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个资源定义如下:

I have a resource defined as follows:

app.factory("DatumItem", function($resource) {
    return $resource('/data/:id', {id: '@id'});
});

在我看来,我有:

<div ng-click="go('/datum/' + d.to_param)">Test</div>

去哪儿()在我的控制器的定义:

where go() is defined in my controller as:

$scope.go = function (params) {
    $location.path(params);
};

有关问题的项目,d.param等于

For the item in question, d.param is equal to

TkZUOWZwcnc9Uldo%0ASzRvd2FiWk

但是,当我打电话DatumItem.get()使用正确的ID,它正在改变ID为

But when I call DatumItem.get() with the correct ID, it is changing the id to

TkZUOWZwcnc9Uldo%250ASzRvd2FiWk

有没有办法来prevent的%,从在这种情况下是连接codeD到25%?

Is there a way to prevent the % from being encoded to a %25 in this case?

我试着使用EN codeURI,连接codeURIComponent无济于事的组合。

I've tried a combination of using encodeURI, encodeURIComponent to no avail.

任何帮助将大大AP preciated,谢谢!

any help would be greatly appreciated, thanks!

推荐答案

由于该网址已经是你需要它传递到前角脱code将其URIen codeD:

Since the URL is already URIencoded you need to decode it before passing it to angular:

$scope.go = function (params) {
    $location.path(decodeURIComponent(params));
};

这篇关于角资源URL编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆