I'm attempting to generate a link that will enable the download of a JSON file in this way
Controller
$scope.url = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj));
View
<a href="url" download="download.json">download</a>
However, upon inspecting the resulting HTML code, I notice that unsafe:
is added at the beginning of the href
value, causing the link to malfunction.
I have made unsuccessful attempts to use different approaches from the $sce
service to indicate to Angular that this URL should be trusted.