I have a src script, which I am placing in the index.html of my angular project, this script will give access to the $example variable, this variable that the script lets me use, is only available within the location where I run it. Example:
<script>
window.$product=[];
window.PRODUCT_ID=ID;
(function(){
d=document;
s=d.createElement("script");
s.src="https://example.com/sdk/main.js";
s.async=1;
d.getElementsByTagName("head")[0].appendChild(s)
})();
$product.method();
</script>
I need execute this .method inside example.component.ts in Angular
I would like to be able to get this variable within my Angular component, but I don’t know if this is possible and I have no idea how programmers with more experience solve this. Because I need to execute what is being made available in $product, because this variable that is in the Window object has some methods that I need to use, but I need it to be within the Angular component and not in the context of index.html.