Incluse Javascript file

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);

html:
html:





Fruit aléatoire

Veuillez cliquer sur le bouton
Salut
résultat

This is extremely unidiomatic Angular. You should let Angular handle DOM interaction - there should never be any document, addEventListener, innerHTML - none of that.

Instead, use property binding to get the random fruit into the template and a (click) handler in the template to call the randomizer.