I am creating a search bar which get projects from API and shows them all are works fine but when I search for #
or any character followed by #
in the search bar nothing returned not "project not found" functionality also. It shows only current page.I am using AngularJS 1.2
Asked
Active
Viewed 396 times
0

Animay
- 602
- 1
- 7
- 18
-
https://stackoverflow.com/questions/21398344/angularjs-search-functionality-is-not-working-when-more-than-one-special-charact – Parth Raval Apr 11 '18 at 12:47
-
Can you provide your code and SQL Query? – Ramesh Rajendran Apr 11 '18 at 12:47
1 Answers
1
The reason being you have to encode the special characters before sending it to the server. You can use encodeURIComponent()
javascript method.
NOTE: encodeURIComponent() will not encode: ~!*()'
To encode the above characters as well, use a custom method.
customEncodeURIComponent = function (tURL) {
return encodeURIComponent(tURL).replace(/[!'()]/g, escape);
};

Gowthaman
- 1,262
- 1
- 9
- 15
-
`escape` method does not encode `@*_+-./` and encodeURIComponent does not encode `~!*()'` . Which means the custom method will not encode `*_-.` You have to include that in the custom method `.replace(/[!'()]/g, escape).replace(/\*/g, "%2A")` This will encode `*`. Refer to this [list](https://www.w3schools.com/tags/ref_urlencode.asp) for other values. – Gowthaman Apr 12 '18 at 14:35
-
I have encoded but Underscore and percentage characters are not working, may be back-end problem – Animay Apr 13 '18 at 10:32