1

I've got this code in phtml file:

<script type="text/x-magento-init">
{
    "*": {
        "Magento_Ui/js/core/app": {
            "components": {
                "livePriceComponent": {
                    "component": "LivePrice"
                }
            }
        }
    }
}

Now, I want to pass some config variables to the LivePrice component. How do I do it using the code above?

1 Answer 1

1

Simply add your config value to the component. But, should remember that the template is a json format template.

For example:

<script type="text/x-magento-init">
{
    "*": {
        "Magento_Ui/js/core/app": {
            "components": {
                "livePriceComponent": {
                    "component": "LivePrice",
                    "configValue" : "<?php echo "Config Value Text"; ?>"
                }
            }
        }
    }
}
</script>

In your Js component, we can get this.configValue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.