mercredi 28 février 2018

Handlebars display object property dynamically by property name


<tr>
    <td>
        
    </td>
     // line 27
        <td>
            
             // what I tried
            
        </td>
    
</tr>


In the template I have a list of modelItems. In the table there are some certain columns displayed but there also might be optional ones in the selectedColumns list. As line 27 I am looping through selectedColumns to display them but no luck. How is it possible Handlebars to display object property dynamically by property name?


in JS it would something like

foreach (items in selectedColumns) {
    console.log(item.name);
    foreach (column in selectedColumns) {
        console.log(item['"'+column+'"']);
    }
}




Aucun commentaire:

Enregistrer un commentaire