Connect a Stimulus Controller to your html

Share this video with your friends

Send Tweet

The first thing you need to do is add the data-controller attribute the to html that you want to connect to Stimulus.

We added data-controller="example" so Stimulus expects an example_controller.js file to exist.

In our ExampleController class, we are going to use the connect method to show that we've connected our controller to the dom.