Assuming I got 2 components like this: How can I pass data from 1 component to another?
In this example I would like to pass some data when I close the modal to "my-component"
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"my-component": {
"component": "XXX_XXX/js/component"
},
"my-modal" :{
"component": "XXX_XXX/js/modal",
}
}
}
}
}
</script>
HTML nesting of the elements
<div class="content col-12" data-bind="scope: 'my-component'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<div class="modal" data-bind="scope: 'my-modal'">
</div>
and this is how the elements look like in the JS at least for now.
define([
'jquery',
'uiElement',
'Magento_Ui/js/modal/modal',
"ko"
], function (jQuery, uiElement, modal, ko) {
"use strict";
return uiElement.extend({})
})
I tired few things, like using the same scope would probably solve my problem but that would leave me with 1 component instead of 2.