title: Angular 7 how to execute script tag from dynamic HTML
body: <p>I'm integrating <code>GrapesJS</code> with <code>Lory slider</code> into angular 7, and I need to load inline scripts that the editor generates to give functionality to the slider.</p>
  
  <p>I need to load dynamically components inside the HTML that's why I use "<strong>dynamic-html</strong>" component.</p>
  
  <p>I've tried to reload the scripts with directives but nothing works, it seems that Angular can't find the element.</p>
  
  <h2><strong>TS</strong></h2>
  
  <pre><code>@Component({
    selector: 'app-paginas',
    styleUrls: ['./paginas.component.scss'],
    encapsulation: ViewEncapsulation.ShadowDom,
    template : `&lt;dynamic-html [content]="pagina.html"&gt;&lt;/dynamic-html&gt;`
  })
  </code></pre>
  
  <h2>Script that editor returns inside "<strong>pagina.html</strong>"</h2>
  
  <pre><code>&lt;script&gt;var items = document.querySelectorAll('#ixuhz');        for (var i = 0, len = items.length; i &lt; len; i++) {          (function(){var e=this,t="https://cdnjs.cloudflare.com/ajax/libs/lory.js/2.3.4/lory.min.js",l=["0","false"],s="";s="true"==s?1:parseInt(s,10);var a={slidesToScroll:parseInt("1",10),enableMouseEvents:l.indexOf("")&gt;=0?0:1,infinite:!isNaN(s)&amp;&amp;s,rewind:!(l.indexOf("")&gt;=0),slideSpeed:parseInt("300",10),rewindSpeed:parseInt("600",10),snapBackSpeed:parseInt("200",10),ease:"ease",classNameFrame:"gjs-lory-frame",classNameSlideContainer:"gjs-lory-slides",classNamePrevCtrl:"gjs-lory-prev",classNameNextCtrl:"gjs-lory-next"},r=function(){window.sliderLory=lory(e,a)};if("undefined"==typeof lory){var n=document.createElement("script");n.src=t,n.onload=r,document.head.appendChild(n)}else r()}.bind(items[i]))();        }&lt;/script&gt;
  </code></pre>
  
  <h2>Expecting get some result but not find anything</h2>
  
  <p><img src="https://i.stack.imgur.com/ryEII.png" alt="Slider Without Script Loading"></p>
  
  <p>Trying to get the element with Jquery or JS</p>
  
  <pre><code>ngAfterViewInit(){
    console.log($("#ixuhz"));
  }
  </code></pre>