I'm trying to get the customer data on on the frontend of a custom template similar to how it is done in:
app/code/Magento/Theme/view/frontend/templates/html/header.phtml
As described in this article.
This is what I have:
<h2>test2:
<span data-bind="text: customer().firstname">
</h2>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"customer": {
"component": "Magento_Customer/js/view/customer"
}
}
}
}
}
</script>
But it throws this error in the browser console:
knockout.js:3012 Uncaught ReferenceError: Unable to process binding
"text: function (){return customer().firstname }"
Best Answer
You're missing the scope, try this:
A complete example using the scope
example-scope
taken from this answer.Template
Component