Hey! i need some help with some js files


#1

so i’m trying to import these librarys in my ionic app, i followed these steps.

  1. install dependences
    npm install mathjs
    npm i d3@3 function-plot
    npm install d3
  2. then i created my custom copy config and add my files

    3.and in my html inside the head i add the link like this


and still doesn’t work :frowning:


#2

That’s good but copy the files to -> dest: ‘{{WWW}}’ as your not ‘building’ them!

In your index.html:

<!doctype html>
<html lang="en" dir="ltr">

<head>

  ...

  <script src="math.js" type="text/javascript"></script>

</head>

<body>

  <script>

    // do math stuff

  </script>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>

  <!-- Styles -->
  <link rel="preload" href="build/main.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
  <noscript><link rel="stylesheet" href="build/main.css"></noscript>

  <noscript>
    <h2 style="padding: 20px; text-align: center;">JavaScript must be enabled to use this application.</h2>
  </noscript>

</body>

</html>

Note: You should create a Service and load your .js files asynchronously: https://stackoverflow.com/questions/34931771/how-to-load-google-maps-api-asynchronously-in-angular2