Search code examples
node.jshandlebars.js

How to use function with foreach in .hbs (Handlebar)?


I am trying using function for .hbs file but not able to do that.Below is the code which i want to use in handlebar

        if(userData.length!=0){
        var i=1;
        userData.forEach(function(data){

I try to use below code but that havn't work

 {{#each userData(function(data))}}
       <h1>{{userData}}</h1>
       {{log data.Dimension_4_Score}}
        {{/each}}

Solution

  • I am able to do it using below code

    <div>
        {{#each userData}}
                   <tr>
                <td>{{User_ID}}</td>
                <td>{{Team_Name}}</td>
                <td>{{Dimension_1_Score}}</td>
                <td>{{Dimension_2_Score}}</td>
                <td>{{Dimension_3_Score}}</td>
                <td>{{Dimension_4_Score}}</td>
                <td>{{Total_Score_Persentage}}</td>
            </tr>
        {{/each}}