1×
Become a member
to unlock all features

Create egghead account to access 5000+ tutorials and resources from expert developers.

Create account
Autoplay

    Extract a Value from an Stimulus Target Input

    javascriptJavaScript

    We will use data-target to tell our controller which input element we are getting our value from.

    We need to declare static targets = ['name'] in our controller to tell which element we are referencing. We then reference the value in the input element with this.nameTarget.value.