I have this code in my.phtml:
<script type="text/x-magento-init"> { "*": { "installment": <?= $block->getConfig(); ?> } } </script>
I want to get the "parcel" data in my custom Js on the checkout page. How can I get?
When mage-init initializes my widget's _create it returns with the filled data.
When I call requirejs it comes with empty data.
define( [ 'ko', 'installation' ], function (ko, installment) {
help
Hello @ervinjelvo9d3a
Kindly refer below link :
Javascript Init
It may help you!
thank you
Hi @ervinjelvo9d3a ,
Please refer below link
https://magento.stackexchange.com/questions/290144/magento-2-pass-variable-from-phtml-to-js
Below is the simple code that you can use in JS.
From above link you will get full idea about pass data and get data.
define([ 'ko', 'uiComponent'
], function (ko, Component) { 'use strict'; return Component.extend({ /** * @override */ initialize: function () { this._super(); this.maxPrice = ko.observable(this.maxpriceShipping); },
});
});
Hope it helps!
Thanks