2

Here is the link I'm using with ui-sref attribute directive:

<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:

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?

Aliunco
  • 399
  • 2
  • 9
  • Possible duplicate of [angular ui.router ui-sref replace url characters - beautify](http://stackoverflow.com/questions/27918231/angular-ui-router-ui-sref-replace-url-characters-beautify) – fracz Sep 30 '15 at 21:32

2 Answers2

2

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:

<a href="{{beautyUri(item.uuid, item.title)}}">{{title}}</a>
Aliunco
  • 399
  • 2
  • 9
0

i hade this problem to but after a lot of unsuccessful searches , find the solution it's very simple actually you can use javaScript decodeURIComponent() function on $scope.item.title for me it's worked like charm .

Pooria.Shariatzadeh
  • 291
  • 2
  • 4
  • 16