Stefan Karlsson Stefan Karlsson - 2 years ago 147
AngularJS Question

angular encode url search string

how do i encode the keyword that get sent to the server and then decode it?

I can't search for keywords containing chars like .? or / at the moment.

The code displaying is wrong because endpoint returns a object. = function (keyword) {
var endpoint = $location.path(baseEndpoint + "search/").search(keyword),
deferred = $q.defer();

$http.get(HttpRequestUrlHelper.ensureUniqueRequestUrl(endpoint), {
}).success(function (response) {
}).error(function (error) {

return deferred.promise;

If i use encodeURIComponent() my url is encoded but my controller isn't hit:

request url => /todo/search/Leka%20med%20barnen.?UniqueKey=1404655031784 angular.js:9159
GET http://localhost:49195/todo/search/Leka%20med%20barnen.?UniqueKey=1404655031784 404 (Not Found)

Answer Source

Ended up making a query string instead:

var endpoint = baseEndpoint + "search?keyword=" + keyword,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download