While you try to redirect anything with url query paremeter with angular property, you may have problem with url encoding. my problem was # character to search with hashtag.
example url which I was going to trying and fall to problem : www.websitename.com/search?searchkey=#somehastagword
if try it like that, you will have problem :
<a href="www.websitename.com/search?searchkey={{ hashtagValue}}"> {{ hashtagValue}} </a>
you should use escape filter as following;
angular.module('angularModuleName').filter('escape', function () {
return function (input) {
if (input) {
return window.encodeURIComponent(input);
}
return "";
}
});
use it in html like that :
<a href="www.websitename.com/search?searchkey={{ hashtagValue | escape }}"> {{ hashtagValue}} </a>
After added angular filter function in our angular app, we solved our problem deal with url parameter escape characters.Now we have result url as following:
http://www.websitename.com/search?searchkey=%23searchkeyword
-
Home / / Angular URL Escape character problem solving
Angular URL Escape character problem solving
Ekim 11, 2017 0
Angular URL Escape character problem solvingYunus Emre Ekim 11, 2017
Yunus Emre
Integer sodales turpis id sapien bibendum, ac tempor quam dignissim. Mauris feugiat lobortis dignissim. Aliquam facilisis, velit sit amet sagittis laoreet, urna risus porta nisi, nec fringilla diam leo quis purus.