I have a problem with a request for backup resources when the uri resource has several subfolders:
Example:
.factory('SomeFactory', function ($resource) {
return $resource('/path/subPath/otherSubPath/:id', {}, {
show: { method: 'GET', params: { id: '@id' } }
})
}) ;
When I call SomeFactory.show in the controller, I get an error the server responded with status 400 (Bad Request) This is because the browser is looking for uri:
http://server/path/subPath%2FotherSubPat/id
Note that% 2F replaces / (slash) in uri, I tried many tricks in javascript to make this work; But the only solution was to add the following replacement for the last line (/% 2F / gi, '/'); in the angular -resource.js encodeUriSegment method.
Please tell me if this approach is correct.
function encodeUriSegment(val) {
return encodeUriQuery(val, true).
replace(/%26/gi, '&').
replace(/%3D/gi, '=').
replace(/%2B/gi, '+').
replace(/%2F/gi, '/');
}
Thanks.
source
share