Problem: You need to display a table with first name, last name and age.
Sample data: Paul Doe, 24 Greg Jones, 31 Able Smith, 29
We will use a function node to create the table like this:
var arr =[["Paul","Doe",24],["Greg","Jones",31],["Able","Smith",29]];
msg.payload = arr;
return msg;
And display the table using the template node. Here is what we use in the template node:
<table id="table" border="1">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tbody>
<tr ng-repeat="row in msg.payload">
<td ng-repeat="item in row" >{{item}}</td>
</tr>
</tbody>
</table>
In this case we use the ng-repeat twice, once to process each row of the table in the and once to display each item in each row using a element.
Here is what the display will look like:
First Name |
Last Name |
Age |
---|---|---|
Paul | Doe | 24 |
Greg | Jones | 31 |
Able | Smith | 29 |