How to print a log with console.log() in knockout template?

Knockout JS with print a log message to the console at a development time.

You can trace or logs any object by the console.log in the knockout JS template.

You can log messages with the given syntax,

<div data-bind="text: console.log(' My Log:', $data)"></div>

Here When you refresh the page, you will see My Log: with your data output in the Browser console.

Just use the text data-bind attribute to log specific JS messages.

How to use foreach loop with the array and objects in knockout js magento?

knockout Javascript with Foreach loops for the observable array and objects with the data-bind property of the DOM tag.

Let’s start with a simple for each loop with an array that contains the numbers only,

JS file contains the knockout declaration of the observable array, called getNumbers property, Continue reading “How to use foreach loop with the array and objects in knockout js magento?”

How to define Require JS Plugin in Magento?

You can create Require JS plugin in Magento with text! as a suffix and pass HTML file path in the dependency of the define( ) method in javascript.

An Example of a text plugin in Magento,

'text!Jesadiya_Blog/template/plugin.html'

Continue reading “How to define Require JS Plugin in Magento?”