I have this script tag:
<script src='//vizor.io/static/scripts/vizor-360-embed.js'
data-vizorurl='//vizor.io/embed/bumblucian/casuta-favorita'></script>
which will put on my website a 3D image (see example 3D images)
I want to create a component which I can use in several places on my website. If I put the script tag as it is, on the html file, is not working.
I tried the answer from this question Adding script tags in Angular component template but I do not know how to add the data-vizorurl
attribut to the script tag.
export class PerspectiveImageComponent implements OnInit {
constructor(private _renderer2: Renderer2, @Inject(DOCUMENT) private _document) {
}
public ngOnInit() {
let s = this._renderer2.createElement('script');
s.src='//vizor.io/static/scripts/vizor-360-embed.js';
// I tried like this, but is not compiling.
s.data-vizorurl='//vizor.io/embed/bumblucian/casuta-favorita';
this._renderer2.appendChild(this._document.body, s);
}
}
Can you help me with a solution?
Edit: if I use s.dataset.vizorurl
is working. I have the script tag on the document, but I have another error:
vizor-360-embed.js:28 Uncaught TypeError: Cannot read property 'previousElementSibling' of null
at findSelfInDocument (vizor-360-embed.js:28)
at vizor-360-embed.js:34
at vizor-360-embed.js:98