0

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.

3
  • What do these functions do? Couldn't you move them to an angular service and inject them on whichever classes you need? Commented Oct 25, 2017 at 13:31
  • I don't know many details, it is to log some actions the user does on the page. Commented Oct 25, 2017 at 13:32
  • 1
    Ok in the end I ended up doing what @wdanda suggested Commented Oct 26, 2017 at 7:44

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.