I'm in the process of upgrading an ArcGIS Javascript API 3.x application to 4.19/20 and having trouble with URLs in my popup.
In 3.x, I was able to set the template content like so, using relative paths to my reports:
var templateContent = "<b>{STATIONNUM} (" + status + ")</b><hr>" +
"<b>Station Name: </b>{STATIONNAM}<br>" +
"<b>Description: </b>{DESCRIPT}<br><br>" +
"<a href='Station/StationReport/{STATIONNUM}' target='_blank'>Full Station Report</a><br><br>" +
"<a href='StationFiles/Files/{STATIONNUM}' target='_blank'>Sketches / Photos</a><br><br>" +
"<a href='https://maps.google.com/maps?q=&layer=c&cbll=" + data[0].latitude + "," + data[0].longitude + "' target='_blank'>Google Street View</a>" +
showSession + "<br/><br/>" + adoptionInfo;
This same code works in 4.x, except for the relative paths. I end up with this in the popup:
<div class="esri-feature-content">
<div>
<b>229327 (Intact)</b>
<hr>
<b>Station Name: </b>Minard Bog<br>
<b>Description: </b> <br><br>
<a href target="_blank">Full Station Report</a><br><br>
<a href target="_blank">Sketches / Photos</a><br><br>
<a href="https://maps.google.com/maps?q=&layer=c&cbll=44.12769707011916,-65.12424322455458" target="_blank">Google Street View</a><br><br>
Not Adopted
</div>
</div>
But, if I put in the full URL, it works properly:
var templateContent = "<b>{STATIONNUM} (" + status + ")</b><hr>" +
"<b>Station Name: </b>{STATIONNAM}<br>" +
"<b>Description: </b>{DESCRIPT}<br><br>" +
"<a href='https://localhost:44322/Station/StationReport/{STATIONNUM}' target='_blank'>Full Station Report</a><br><br>" +
"<a href='https://localhost:44322/StationFiles/Files/{STATIONNUM}' target='_blank'>Sketches / Photos</a><br><br>" +
"<a href='https://maps.google.com/maps?q=&layer=c&cbll=" + data[0].latitude + "," + data[0].longitude + "' target='_blank'>Google Street View</a>" +
showSession + "<br/><br/>" + adoptionInfo;
result:
<div class="esri-feature-content">
<div>
<b>229327 (Intact)</b>
<hr>
<b>Station Name: </b>Minard Bog<br>
<b>Description: </b> <br><br>
<a href="https://localhost:44322/Station/StationReport/229327" target="_blank">Full Station Report</a><br><br>
<a href="https://localhost:44322/StationFiles/Files/229327" target="_blank">Sketches / Photos</a><br><br>
<a href="https://maps.google.com/maps?q=&layer=c&cbll=44.12769707011916,-65.12424322455458" target="_blank">Google Street View</a><br><br>
Not Adopted
</div>
</div>
Seems like a bug me? Has anyone else experienced this?
Solved! Go to Solution.
It doesn't work.
In Angular:
"this" doesn't work in functions formatTitle and formatContent.