Shahenshah Malik
09/12/2024, 3:19 AMgd-dashboard
based on the workspace ID received from an API response. The workspace ID is required in the GoodData script, which I would typically add to the <head></head>
section of the HTML.
However, Angular treats dynamically adding scripts as a security issue and prevents this from being done. Is there a way to load the GoodData script dynamically in Angular without violating Angular's security restrictions? Or, is there another approach to loading the GoodData web component in this scenario?
Any help would be greatly appreciated.
Thank you!Jakub Vajda
09/13/2024, 9:57 AMDomSanitizer
library.
There is a thread on StackOverflow, that nicely describes how to mark that URL as safe:
• bypassSecurityTrustResourceUrl should be generally avoided as it may expose application to security risks
• sanitize is then the function that will create a safe and trusted value, you should be able to dynamically import.
I hope it helps.Shahenshah Malik
09/13/2024, 11:17 AMShahenshah Malik
09/14/2024, 6:48 AM@if(dashboardId) {
{{dashboardId}}
<gd-dashboard class="dashboard" dashboard="{{dashboardId}}" #dashboard></gd-dashboard>
}
@else {
<div class="error">No dashboard ID provided</div>
}
Shahenshah Malik
09/14/2024, 6:49 AMShahenshah Malik
09/14/2024, 6:49 AMShahenshah Malik
09/14/2024, 7:23 AMconst gdElement = document.createElement('gd-dashboard');
gdElement.classList.add('dashboard');
gdElement.setAttribute('dashboard', this.dashboardId);
document.getElementById('dashboardContainer').appendChild(gdElement);