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.
Asked
Active
Viewed 373 times
0
-
What do these functions do? Couldn't you move them to an angular service and inject them on whichever classes you need? – Wagner Danda da Silva Filho Oct 25 '17 at 13:31
-
I don't know many details, it is to log some actions the user does on the page. – gyozo kudor Oct 25 '17 at 13:32
-
1Ok in the end I ended up doing what @wdanda suggested – gyozo kudor Oct 26 '17 at 07:44
1 Answers
1
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.

Wagner Danda da Silva Filho
- 4,958
- 9
- 39
- 49