/app/design/frontend/Vendor/custom_theme/Magento_CheckoutAgreements/templates/additional_agreements.phtml
I have this code inside .phtml:
<div data-bind="scope: 'checkout-agreements-component-scope'" class="checkout-agreements-block">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"checkout-agreements-component-scope": {
"component": "Magento_CheckoutAgreements/js/view/checkout-agreements",
"agreements": <?php /* @noEscape */ echo $agreementJson; ?>,
"isVisible": true,
"exampleMessage": "<?php echo 'Hello Magento Stack Exchange!'; ?>",
"sarfaraj": "<?php echo 'I am Back....!' ?>"
}
}
}
}
}
</script>
/app/design/frontend/Vendor/custom_theme/Magento_CheckoutAgreements/web/js/view/checkout-agreements.js
inside .js:
return Component.extend({
defaults: {
exampleMessage: 'Default Text Ready',
sarfaraj: 'Raj',
template: 'Magento_CheckoutAgreements/checkout/checkout-agreements'
},
initialize: function() {
this._super();
console.log(this.exampleMessage);
this.message = ko.observable(this.exampleMessage);
console.log(this.sarfaraj);
this.FIR = ko.observable(this.sarfaraj);
}
});
/app/design/frontend/Vendor/custom_theme/Magento_CheckoutAgreements/web/template/checkout/checkout-agreements.html
inside .html:
<h2 data-bind="text: message"></h2>
<h3 data-bind="text: FIR"></h3>
My OUTPUT at Checkout page:
Help Me. Thanks.
text/x-magento-init
call before your data-bindings. I don't think this is the issue but I have seen stranger things happen!require()
call in your JS code please just to make sure that is ok.