How to load external scripts dynamically in Angular?

前端 未结 15 1059
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:48

I have this module which componentize the external library together with additional logic without adding the

15条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 07:14

    @rahul-kumar 's solution works good for me, but i wanted to call my javascript function in my typescript

    foo.myFunctions() // works in browser console, but foo can't be used in typescript file
    

    I fixed it by declaring it in my typescript :

    import { Component } from '@angular/core';
    import { ScriptService } from './script.service';
    declare var foo;
    

    And now, i can call foo anywhere in my typecript file

提交回复
热议问题