Im looking for a way to access a variable from external js file which i included in assets/data folder
below is what i tried
placed test.js
in assets/data folder
in test.js
added variable testvar = "heloo from external js";
added script tag in src/index.html
<script src="assets/data/test.js"></script>
in app.component.ts
i added this line after imports;declare var testvar: any;
in constructor added this line to log the value console.log(testvar);
result is error : ERROR ReferenceError: testvar is not defined
so, how can i use my js variable in typescript ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…