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

前端 未结 2 2008
旧时难觅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:06

    Besides doing a declare var which tells ts that the variable exists you can use typings of typescript. By writing

    typings install libraryname
    

    In your console you get a file that already has declare var/class and you can see all of its functions/properties when you import it.

    import {lib} from 'libraryname';
    

提交回复
热议问题