How can I include external js files in ionic 3

0

I'm working with ionic 3 and I try to work with js files ... I followed another post where they ask me to add some things in index.html and app.component.ts (and I have done it) but when wanting to show in console what contains the variable declared in the js, it marks me as undefined, but it is assumed that and call the js file on the previous pages ... could someone tell me why it does not work for me?

    
asked by Choche 08.05.2018 в 14:40
source

1 answer

1

This is the code

test.js

var testvar = "Hola mundo en js y llamado desde ionic 3";

index.html

<!-- cordova.js required for cordova apps (remove if not needed) -->
  <script src="cordova.js"></script>
  <script src="assets/js/test.js"></script>

app.component.ts

import * as test from '../assets/js/test';
declare var testvar;
console.log(test.testvar);//Aqui mando a mostrar el mensaje (undefined)
    
answered by 08.05.2018 в 15:03