Incluse Javascript file(corrected)

Sorry, I made a bad post. I publish the corrected poste:

Hello every Body. I have creat a little script for test something.
I search a solution regarding the inclusion a Js file.

Javascript

const btn = document.querySelector(“ion-button”);
const fruits = [“banane”, “cerise”, “orange”, “raisin”, “ananas”];
const result = document.querySelector(".result");

function random(){
let fruit_random = Math.round(Math.random()*(fruits.length-1));
console.log(fruits[fruit_random])
result.innerHTML = fruits[fruit_random]

}
btn.addEventListener(“click”, random); //bad

html:

<ion-header>
  <ion-toolbar class="head_fond">
    <ion-buttons slot="start">
      <ion-back-button defaultHref="/tab1" text="tab 1"></ion-back-button>
    </ion-buttons>
    <ion-title>Fruit aléatoire</ion-title>
   
  </ion-toolbar>
</ion-header>
  
<ion-content class="fond">
  <ion-label classe="label1">Veuillez cliquer sur le bouton</ion-label><br>
  <ion-button id="ion-button" class="button">
    <ion-label class="label_button">Salut</ion-label>
  </ion-button><br>
  <ion-label classe="label2">résultat</ion-label><br>
  <ion-label class="result"></ion-label>
  <script src="script.js"></script>

</ion-content>

the scipt works if it is in "ngOnInit () {

}; " of sociale.ts

Capture

Emulate the Tour of Heroes.

And to add to it - you cannot do this in an angular template. While it has extension html, it actually isn’t html. The only true html in an angular app is is to be found in index.html.

Understanding angular through the ToH recommendation by @rapropos is recommendable after which you may want to redefine your need.