I see some Stimulus controllers that assign component settings using:
data-mycontroller-foo="bar"
in the HTML and then retrieving this value using this.data.get("foo")
in the controller.
This makes assigning initial values a little cleaner (don’t need to append -value
to the HTML attribute, and don’t need to declare the value in the controller.
I understand that this doesn’t allow you to reactively manage that value from the controller and I don’t see it documented anywhere in the Stimulus handbook.
Just wondering if this is a legacy data access mechanism that should be avoided, or is it an acceptable alternative for when you have initial values that you know you don’t need to be reactive?