Search code examples
angulartypescriptangular2-clitype-definition

How do I use global functions from a javascript library inside angular 2


I'm using angular-cli. I have an index.html that has a script (javascript) with some global functions in it. I want to use these functions in several places in my app. I'm fairly new to Angular and typescript and I know very little about type definitions. I tried writing type definitions but I have trouble writing and/or importing them. Can someone give me an example how to do this? It would be nice if I could import all the functions with just one line.


Solution

  • As suggested in my comments, I'd ask my self why not port these functions into a proper angular service that can be injected to classes that need to use them.