Angular 2 typescript invoke javascript function

后端 未结 1 1451
自闭症患者
自闭症患者 2020-12-01 19:46

Is there a correct way to invoke a JavaScript function from a component in Angular 2 (TypeScript) ?

Here is my component :

import { ElementRef, After         


        
相关标签:
1条回答
  • 2020-12-01 20:04

    You have to tell TypeScript about external (JavaScript) declarations using declare. See https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html

    interface MyTheme {
        documentOnLoad: Function;
        documentOnReady: Function;
    }
    declare var MYTHEME: MyTheme;
    

    Or anonymously

    declare var MYTHEME: {documentOnLoad: Function, documentOnReady: Function};
    
    0 讨论(0)
提交回复
热议问题