Interpolating data

Let's imagine the following piece of HTML code:

<div id="hello"></div> 

Also, imagine the following JavaScript object:

var data = { 
  msg: 'Hello' 
}; 

How can we render the values of data entries on the page? How can we access them so that we can use them inside our HTML? Actually, we have been doing this a lot with Vue.js during the last two chapters. There is no problem in understanding and doing it again and again.

"Repetitio est mater studiorum"

If you are already a professional of data interpolation, just skip this section and proceed to the expressions and filters.

So, what should we do to populate the <div> with the value of msg? If we go the old-fashioned jQuery way, we would probably do something like the following:

$("#hello").text(data.msg); ...

Get Learning Vue.js 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.