In our AngularJS application we want to integrate the third party JS file like this.
<script id="myID"
type="text/javascript"
data-encoding="jsonb"
data-model="MyModelName"
data-object="dfdsfsdfsdftrggregerigherignrtintrgntrgjntrjhintrhirnrgoigtrg"
src="//plugin.wwwwww.ee/js/myreference.js"></script>
But we want to create above Script tag runtime so we can get value for data-model,data-object & data-encoding (By Using Controller or other technique)
When we try to add JS file runtime we are getting error in our refered file.
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.
on document.write(-----------);
So what is the exact problem, We are using following code on Index.html for adding that JS reference.
var srcFeedback = document.createElement('script'),
body = document.getElementsByTagName('body')[0];
srcFeedback.src = '//vbvcbcvb.bvbcvb.nl/js/ref.js';
srcFeedback.id = "_plugin_id";
srcFeedback.type = 'text/javascript';
srcFeedback.setAttribute("data-encoding", "rrrrrrr");
srcFeedback.setAttribute("data-model", "rrrrrrrrrrr");
srcFeedback.setAttribute("data-object", "regrgegergergvtrcgxercgtrvghtrgtrhct");
body.appendChild(srcFeedback);
Or is there any alternative way?