How to include external Javascript library in an Ionic 2 TypeScript project?

前端 未结 2 2025
旧时难觅i
旧时难觅i 2020-12-10 07:44

I build an Ionic Project using Ionic 2, Angular 2 and TypeScript to test the framework a bit. I need to include an external library (ntc.js) to my project, since I need it t

2条回答
  •  难免孤独
    2020-12-10 08:16

    You import it by adding it to your index.html like any other regular javascript file.

    Then in your ts file you do:

    declare var Tree:any; 
    

    Then in your code, you can use the Tree variable, albeit it exists in the Javascript file. this line of code is basically telling the typescript compiler there is a variable out there Tree which it should ignore.

提交回复
热议问题