Start your All-Access Pass to unlock this challenge
How can I pass some data - e.g. an id of an item - from one Stimulus controller to another?
id
You cannot communicate between controllers, but this is by design. One controller should not have any awareness of any other controller.
By dispatching an event as this.dispatch('event:name', null, { id: item.id });
this.dispatch('event:name', null, { id: item.id });
By dispatching an event as this.dispatch('event:name', { id: item.id });
this.dispatch('event:name', { id: item.id });
By defining a global variable in connect() - e.g. window.id = 5 - and referencing that in the other controller.
connect()
window.id = 5