You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
474 B
20 lines
474 B
import { Controller } from "@hotwired/stimulus";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["hello"];
|
|
|
|
connect() {
|
|
console.log(
|
|
"Hello once from the controller !",
|
|
this.element,
|
|
this.helloTargets
|
|
);
|
|
}
|
|
|
|
sayHi() {
|
|
const ways_to_say_hello = ["Hello", "Hi", "Good Morning", "G'day"];
|
|
const index = Math.floor(Math.random() * ways_to_say_hello.length);
|
|
|
|
this.helloTarget.innerText = ways_to_say_hello[index];
|
|
}
|
|
}
|
|
|