简体   繁体   中英

How do I access data in array using javascript TEMPO

Been searching all day and still stuck on trying to access data from array object using Tempo.Tried using a variety of processes but not getting anywhere.

The array object that I'm trying to access is called options and the key is name.

<p>{{options:name}}</p>

It's kind of difficult to answer this without at least on instance of the array object. I would suppose you have something like this:

var data = {options:[
    {name:'Test Name'},
    {name:'Another Test Name'}
]}

Just assign the options array to the data method after prepare in Tempo:

Tempo.prepare('container').data(data.options);

And in the HTML:

<div id="container">
    <p data-template>{{name}}</p>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM