When utilizing ng-resource
to send a string to the server, I encountered an issue. If I include &
in the string, anything following it is not transmitted to the server.
For instance, sending this string:
"This section of the string is visible & this part is omitted"
results in everything after &
being removed before reaching the server.
Below is a functional code example illustrating this problem.
angular.module('testApp', ['ngResource'])
.service('TestService', testService)
.controller('Controller', theController);
function testService() {
this.$get = get;
get.$inject = ['$resource'];
function get( $resource ) {
var baseUrl = window.location['origin'];
var theResource = $resource(
baseUrl + '/test_url',
{},
{
testMe: {method: 'GET', url: '/test_url'}
}
)
return theResource;
}
}
theController.$inject = ["TestService"];
function theController(TestService) {
activate();
function activate() {
var stringToSend = "this part of the string is displayed & this part will be missing";
// The server will only receive "this part of the string is displayed &"
TestService.testMe({stringParam: stringToSend}, function(resp) {});
}
}
How can I resolve this issue?
PS: By 'not shown,' I mean that portion of the string seems to vanish during transmission.