I have created one module where I want to pass Parameters using JS.
So I have followed as per below.
app/code/namespace/modulename/view/frontend/templates/index.phtml
<div class="example-element" data-mage-init='{"namespace_modulename/example": {"config": "value"}}'>A single div</div>
app/code/namespace/modulename/view/frontend/web/example.js
define([], function(config){
alert(config);
});
In Alert it should show value as a result but it is showing undefined. Am I doing anything wrong there?