Hi all,
I have some issues to display an array in a table with an html template.
When I use the UI table it works correctly but when I use the same html code in a template node the data doesn't show up.
Array:
[{"ID":14,"melder":"Test","locatie":"ergens"},{"ID":3,"melder":"Test2","locatie":"ergens2"},{"ID":26,"melder":"Test3","locatie":"ergens3"}]
HTML code I use in the Template Node:
<html>
<head>
<title>Formulier</title>
</head>
<body>
<table style="height:auto">
<tr>
<th>ID</th>
<th>Melder</th>
<th>Locatie</th>
</tr>
<tr ng-repeat="x in msg.payload | limitTo:50">
<td>{{msg.payload[$index].ID}}</td>
<td>{{msg.payload[$index].melder}}</td>
<td>{{msg.payload[$index].locatie}}</td>
</tr>
</table>
</body>
</html>
Flow:
[
{
"id": "363608d05129e132",
"type": "ui_template",
"z": "bc462073da9f0465",
"group": "83ea2fa55ee10ce1",
"name": "UI table",
"order": 9,
"width": "18",
"height": "11",
"format": "<table style=\"height:auto%\">\n\n <tr>\n <th>ID</th>\n <th>Melder</th> \n <th>Locatie</th>\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:50\">\n <td>{{msg.payload[$index].ID}}</td>\n <td>{{msg.payload[$index].melder}}</td> \n <td>{{msg.payload[$index].locatie}}</td>\n </tr>\n</table>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"x": 640,
"y": 1520,
"wires": [
[]
]
},
{
"id": "28199df4828ed016",
"type": "http in",
"z": "bc462073da9f0465",
"name": "",
"url": "test1",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 230,
"y": 1480,
"wires": [
[
"7c23884fcba9d896"
]
]
},
{
"id": "1d668fe7fae31712",
"type": "template",
"z": "bc462073da9f0465",
"name": "HTML",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<html>\n <head>\n <title>Formulier</title>\n </head>\n <body>\n<table style=\"height:auto\">\n\n <tr>\n <th>ID</th>\n <th>Melder</th> \n <th>Locatie</th>\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:50\">\n <td>{{msg.payload[$index].ID}}</td>\n <td>{{msg.payload[$index].melder}}</td> \n <td>{{msg.payload[$index].locatie}}</td>\n </tr>\n</table>\n\n</body>\n</html>",
"x": 550,
"y": 1480,
"wires": [
[
"a8b9109e872c3b51"
]
]
},
{
"id": "a8b9109e872c3b51",
"type": "http response",
"z": "bc462073da9f0465",
"name": "",
"x": 650,
"y": 1480,
"wires": []
},
{
"id": "6a8a4b94944551bb",
"type": "inject",
"z": "bc462073da9f0465",
"name": "inject",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 270,
"y": 1520,
"wires": [
[
"7c23884fcba9d896"
]
]
},
{
"id": "7c23884fcba9d896",
"type": "function",
"z": "bc462073da9f0465",
"name": "function 37",
"func": "msg.payload = [{\"ID\":14,\"melder\":\"Test\",\"locatie\":\"ergens\"},{\"ID\":3,\"melder\":\"Test2\",\"locatie\":\"ergens2\"},{\"ID\":26,\"melder\":\"Test3\",\"locatie\":\"ergens3\"}];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 1480,
"wires": [
[
"363608d05129e132",
"1d668fe7fae31712",
"61b800a1947cd0da"
]
]
},
{
"id": "61b800a1947cd0da",
"type": "debug",
"z": "bc462073da9f0465",
"name": "debug 47",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 560,
"y": 1440,
"wires": []
},
{
"id": "83ea2fa55ee10ce1",
"type": "ui_group",
"name": "Dashboard",
"tab": "a1921e.396b2de",
"order": 1,
"disp": true,
"width": 19,
"collapse": true
},
{
"id": "a1921e.396b2de",
"type": "ui_tab",
"name": "Home",
"icon": "home",
"order": 1,
"disabled": false,
"hidden": false
}
]
Does anybody know what's wrong?
Thank you in advance!
Duuk