So I have my index.html, home.page.html and js/externaljs file setup, but can't get the externaljs file to return my function specifically to an id="demo" link on my home.page.html so that it won't display on my app. Need help with the coding to target the return value from my function to the id=demo, I've tried most other options on Angular documentation, no luck...
Here's Code from home.page.html file:
<ion-header [translucent]="true">
<ion-toolbar color="primary">
<ion-title>
RANDOM WORD Generator!
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="false">
<div id="container" class="ion-margin">
<strong>RANDOM WORD GENERATOR</strong>
<ion-card>
<ion-card-header>
<ion-card-title>RANDOM WORD:</ion-card-title>
</ion-card-header>
<ion-grid>
<ion-row>
<ion-col>
<ul>
<li>OR</li>
<li>AND</li>
<li>HIS</li>
</ul>
<p id="demo"></p>
<ion-button color="dark" expand="full" (click)="CallExternalJSFileFunction()">Call External JS File Function</ion-button>
<script src="./myplace/assets/js/swgenfile.js"></script>
</ion-col>
</ion-row>
</ion-grid>
</ion-card>
</div>
</ion-content>
Here's swgenfile.js file:
var randomWord = [ ]
randomWord[0] = "or";
randomWord[1] = "is";
randomWord[2] = "he";
randomWord[3] = "she";
randomWord[4] = "his";
randomWord[5] = "their";
randomWord[6] = "day";
function randomWord () {
var randomWordGen = Math.floor(Math.random()*(randomWord.length));
document.getElementById('pSightWord').innerHTML = randomWord[randomWordGen];
}
Again, trying to get above files to communicate and place a random word in the "placeholder" within my Angular/Ionic app - but its not working obviously. Appreciate any help and input, sorry for the delay - been busy doing everything but learning coding - COVID!