0

I developped an Angular 12 app, and i'm trying to import the .js file in my components. I tried to import it like this

import * as script from 'src/assets/js/home/home.js';

but the .js files are not found, i tried with .ts and there is no problem. Why does the .js files can't be imported like this and how can I import it.

Chatcal
  • 47
  • 2
  • 9
  • 1
    Does this answer your question? [Angular 2: import external js file into component](https://stackoverflow.com/questions/37081943/angular-2-import-external-js-file-into-component) – Rukshan Jayasekara Oct 19 '21 at 14:39
  • try `import from 'src/assets/js/home/home.js';`. You could also include it in the `angular.json` file in the `scripts` section. – Igor Oct 19 '21 at 14:39
  • @Rukshan No because in this case the path found the file and in mine it not. – Chatcal Oct 19 '21 at 15:04

1 Answers1

0

The base path in angular.json is set to the src directly.

Hence you can directly call this

import * as script from 'assets/js/home/home.js';
mak15
  • 367
  • 2
  • 12