0

In my Angular 7 project, in src folder, I have site.js file where I keep some javascript functions.

This file is referenced in angular.json (under scripts section) and all seems ok. Inside index.html, I see that all functions from site.js are available.

How do I run any of the functions from angular component? It seems that my site.js is ignored by component.

Thanks

bobetko
  • 5,019
  • 14
  • 58
  • 85

1 Answers1

-1

You have to import site.js into the component in which you would like to use it:

import myFunction from 'site.js';

or whatever the appropriate import form for your module would be.

See here: How to include external js file in Angular 4 and call function from angular to js.

You've done everything in the answer except the last step.

night_owl
  • 856
  • 6
  • 12