[Angular] script-tag for external video didn't work

8 views
Skip to first unread message

Stephan Fischer

unread,
May 8, 2020, 1:53:04 PM5/8/20
to Angular and AngularJS discussion
In a component I'd like to show video from an external video-service. The video-service gave me a "<script>"-tag (with an externel source) to use it in my html where the video should be shown. I didn't get it :(

First I tried it with the Renderer2 - creating a "script"-element and appent it to an element in the component. In the inspector I can see the script-element, but it wasn't executed - there was no request to the external src (no entry in network).

Than I tried it with Pipe and sanitizer.bypassSecurityTrustHtml(). But I got the same result - I can see it in the inspector, but the external source wasn't loaded.

Has anybody of you the same problem and solved it?  Or can give me same help? I tried out so much example from google, but nothing works.

Thank you,
Stephan

bastien lemaire

unread,
May 8, 2020, 2:15:44 PM5/8/20
to Angular and AngularJS discussion
Looks like the video player requires additional Javascript to run. you need to include the js in the assets.
It's fine to do so but the javascript will be loaded on application load which will increase the initial bundle size.

It's fine in most cases but you wanna watch what you're adding for fast applications.

The plugin tells you to add "<script src="http://www.site.com/script.v1.js></script>" then you take the content of "src" and add it to the scripts array in the angular.json

The official angular documentation is available here: https://angular.io/guide/workspace-config#style-script-config

Should be simple enough
Reply all
Reply to author
Forward
0 new messages