step by step
-
create a script loading service with the script loading function
@Injectable() export class ScriptLoadService {}
-
import it as a provider to your app module
providers: [ScriptLoadService]
-
define it in your constructor in the component that uses the map
constructor(private load: ScriptLoadService) {}