dynamic script loading

How to in Angular?

We create a service that loads the script!

		
			public loadScript(url, id, c): void {
		    if (!document.getElementById(id)) {
		      const script = document.createElement('script');
		      script.type = 'text/javascript';
		      script.src = url;
		      script.id = id;
		      script.addEventListener('load', function (e) {
		         c(null, e);
		      }, false);
		      document.head.appendChild(script);
		    }
		  }