• Angular URL Escape character problem solving

    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:

  • You might also like