I'm using ArcGIS javascript to pass some value from map service to front-end HTML.
I use ${parameter_name}
syntax and pass it into HTML by
var html = [];
html.push('<div>Parameter value is ${parameter_name}</div>');
InfoTemplate.setContent(html);
So that my HTML page will show an InfoTemplate holding
Parameter value is XXX
But now I want to get the value XXX
and edit it before push it into html
. How should I get the value in my javascript?
You can use a function in the parametrized template like this below:
myEditFunction = function(parameterValue) {
//here you can edit the value before returning it
return parameterValue;
}
var html = [];
html.push('<div>Parameter value is ${parameter_name:myEditFunction}</div>');
InfoTemplate.setContent(html);
See the documentation vor API v3.26: https://developers.arcgis.com/javascript/3/jshelp/intro_formatinfowindow.html especially the Using custom functions section.