0

I just followed their guide

<html lang="en">
  <head>
    <title>Your page</title>
    <script src="/js/le.min.js"></script>
    <script>
    // Set up le.js
    LE.init('YOUR-LOG-TOKEN');
    </script>
 </head>

<script>
// log something
LE.log("Hello, logger!");
</script>

I added those in my index file but throwing http://localhost:4200/js/le.min.js net::ERR_ABORTED 404 (Not Found)

k11k2
  • 2,036
  • 2
  • 22
  • 36
  • How did you import it exactly? Did you include it in your Angular CLI config file? Or did you use another method? – Edric Jan 17 '19 at 13:51
  • no, I haven't. with what key name I need to include. I just install `le_js` through npm. – k11k2 Jan 17 '19 at 13:55

1 Answers1

0

You can add a JavaScript file to your Angular app by adding a scripts property to your app project in the Angular app's workspace file (aka angular.json in your project's root directory):

{
  "version": 1,
  // ...
  "projects": {
    "my-app": {
      // ...
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            // ...
            "scripts": [
              // JavaScript file goes here
              "js/le.min.js",
              // Note: The `scripts` property accepts an array of objects or an array of strings
              // See https://github.com/angular/angular-cli/blob/c5de8e3b0e5c1499a0a17da0208297cd82b36095/packages/angular_devkit/build_angular/src/browser/schema.json#L390-L419 for more info
            ]
            // ...
          }
          // ...
        }
        // ...
      }
    }
    // ...
}

Alternatively, you can set this with the ng config command:

# Replace my-app with your actual project name in your angular.json file
ng config projects.my-app.architect.build.options.scripts[0] js/le.min.js
Edric
  • 24,639
  • 13
  • 81
  • 91
  • it generating file but no content in it. what I did is I just put that file in assert folder then it start pulling it. – k11k2 Jan 23 '19 at 09:58
  • Wait... why would you put `angular.json` in the assets folder? It's meant to be a configuration file for the Angular CLI in the project. – Edric Jan 23 '19 at 10:30
  • Oh... I see what you mean. – Edric Jan 23 '19 at 10:32
  • Although you should still use the `scripts` property to add JavaScript files. – Edric Jan 23 '19 at 10:32