[英]how to stop ui-sref encoding url params
Here is the link I'm using with ui-sref
attribute directive:这是我与
ui-sref
属性指令一起使用的链接:
<a ui-ref="show.hastitle({uuid:item.uuid, title:item.title})">
Title parameter can be a Persian word, and what I expect is such as link below:标题参数可以是波斯语单词,我期望的是如下链接:
http://domain.com/page/54c82de2978af/واژه-فارسی
but ui-sref
returns like below:但
ui-sref
返回如下:
http://domain.com/page/54c82de2978af/%D9%88%D8%A7%DA%98%D9%87-%D9%81%D8%A7%D8%B1%D8%B3%DB%8C
I've used such solutions as below:我使用了以下解决方案:
var noneEncodedUri = {
encode: function(str) { return str && str.replace(/ /g, "-"); },
decode: function(str) { return str && str.replace(/-/g, " "); },
is: angular.isString,
pattern: /[^/]+/
};
$urlMatcherFactoryProvider.type('noneEncodedUri', noneEncodedUri);
$stateProvider.state('mystate', {
url: "/{title:noneEncodedUri}"
})
But the rendered link didn't change how can I stop ui-sref
encoding url params completely?但是呈现的链接没有改变我怎样才能完全停止
ui-sref
编码 url 参数?
I've used this scope function to solve my issue:我使用这个范围函数来解决我的问题:
$scope.beautyUri = function (uuid, title) {
return decodeURIComponent($state.href("show.hastitle", {uuid: uuid, title: title}));
};
and use this function in html like this:并在 html 中使用此函数,如下所示:
<a href="{{beautyUri(item.uuid, item.title)}}">{{title}}</a>
我已经解决了这个问题,但是经过很多不成功的搜索,找到了解决方案,它非常简单,实际上您可以在$scope.item.title
上使用 javaScript decodeURIComponent()
函数,它就像魅力一样工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.