Template - Rails 7 view component Projet d'origine: Veracyte Stack: - Rails 7 - Ruby 3.1 - ViewComponent configuré comme on veut - Tailwind
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.
 
 
 
 
 
rails_view_component/app/components/demo/component_controller.js

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];
}
}