I have a javascript code created server side and passed to the client as a string by a rest request. I am trying to execute the code retrieved. Any help would be appreciated.
Server side. The javascript code stored in a string.
(function() {
function createChart(selector) {
$(selector).highcharts({
chart: {
type: 'column',
},
xAxis: {
crosshair: true,
type: "category"
},
yAxis: {
min: 0,
title: {
text: null
}
},
series: [{
data: datas
}],
});
}
function render() {
createChart('#chart');
}
return {
render: render
}
}())
Client side (angular js)
.controller('ChartController', ['$scope', 'charts',function ($scope, charts) {
var test = charts.data;//contains the javascript code send by a rest request
eval(test);
test.render();
}])
The execution of the script in the client side returns "test.render is not a function" in chrome
Any advices ?
Thank you very much