Sunday, 16 April 2017

Define global scope of a variable EJS with node JS

Here is the snippet.

<% console.log('.................. upper count', count); %> //count is undefined...

//data object is getting from node script
<% for(var i=0; i < data.length; i++) { %> 
  <tr>
      <td>data</td>
  </tr>
<% var count = i + 1; 
  console.log("................", count); //Here I got count = 2
%>
<% } %>

Is there any way to print a value of count at the first line that we have got from the count inside the for loop?



via Harsh Patel

No comments:

Post a Comment