I want to show some ads to my website. I thought it will be just - place following tag somewhere:
<script src="https://somewhere.to.go.com" type="text/javascript"></script>
Unfortunately No :/ For a SPA like Angular it is not so easy, because I can´t execute Code inside the Application. Just in the index.html. But that looks awful. So my research brought me to
How to load external scripts dynamically in Angular?
I followed the instructions, but then I got the error message:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
So I found out this is a really tricky problem, because the third-part ad-script returns a code within a document.write command. Allright next research bring me to:
Javascript ads in Angular templates or this Load external JS that has document.write in Angular2
Sounds like postscribe is the solution for my problem. But...it does NOT work. Can´t believe nobody asked this. This is just for AngularJS. I am using Angular 11 and it is not possible to add postscribe to my app.module.ts :( npm install, add by html-tag - nothing work. So my questions here:
Does it really just don´t work for me? Is there some alternativ module for postscribe? Is there some alternativ to get a workaround with the document.write problem?
Thanks a lot for any help and any ideas!