# Get different messages from ui-template while using ng-repeat

**URL:** <https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808>\
**Category:** Dashboard\
**Created:** [1 March 2021 12:59 UTC](https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808 "2021-03-01T12:59:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YT2310](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yt2310/32/35255_2.png) [@YT2310](https://discourse.nodered.org/u/YT2310)\
**Post date:** [1 March 2021 12:59 UTC](https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808/1 "2021-03-01T12:59:05Z")

</div>

Hey there,

I am trying to get a feedback from a table by using the template node.  
Therefore I want to give every row a link (works like a button) so that i can choose between the rows (see first screenshot).  
The goal is that with every link I press on the surface, my template node sends the payload of the row number. (e.g. click link in row 1 will return a 1).

Can someone help me?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5c79ef63d6efbc66188325f7d56b7203ef401f5e.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/829058fcf2ae3b6f7f9180dc1b1e30dc21d1435c.png)

```auto
[{"id":"ef9961f6.80aa5","type":"function","z":"b16c9500.96faa8","name":"","func":"var test = [];\n\nfor(var i=0; i<3 ;i++)\n{\n tabelle = {\n value1:3,\n value2:1,\n value3:i\n }\n test.push(tabelle);\n}\nmsg.payload = test;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":200,"wires":[["8217b659.6ef9a8","ca14e8c6.b69ce8"]]},{"id":"41f6083e.c5b108","type":"inject","z":"b16c9500.96faa8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":370,"y":200,"wires":[["ef9961f6.80aa5"]]},{"id":"8217b659.6ef9a8","type":"ui_template","z":"b16c9500.96faa8","group":"757cd4c6.20854c","name":"","order":1,"width":"20","height":"6","format":"<!DOCTYPE html>\n<html>\n<head>\n<style>\n@media screen {\n table, td, th { \n border: 1px solid #ddd;\n text-align: center;\n }\n\n table {\n border-collapse: collapse;\n table-layout: auto;\n width: auto;\n empty-cells: show;\n }\n\n th, td {\n padding: 12px;\n }\n tr:hover {font-size: 100%;color:#00c6f2;text-decoration: none; font-weight: 400;} /* {background-color:#00c6f2;} Teubert grün #65632e*/\n\n}\n\n</style>\n<script>\nvar value = \"\";\n// or overwrite value in your callback function ...\nthis.scope.action = function() { return 1; }\n\n</script>\n\n</head>\n\n<table class=\"table\" style=\"font-family: Arial, Verdana\">\n <tr>\n <th><font size=2><font color=#00c6f2 ><b>column1</b></font></font></th>\n <th><font size=2><font color=#00c6f2 ><b>column2</b></font></font></th>\n <th><font size=2><font color=#00c6f2 ><b>column3</b></font></font></th>\n </tr>\n \n <tr ng-repeat=\"stuff in msg.payload\">\n <td>{{::stuff.value1}}</td>\n <td>{{::stuff.value2}}</td>\n <td><a href={{::stuff.value3}} ng-click=\"send({payload:action()})\" target=\"_blank\"> showView </a></td>\n </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":700,"y":200,"wires":[[]]},{"id":"ca14e8c6.b69ce8","type":"debug","z":"b16c9500.96faa8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":140,"wires":[]},{"id":"757cd4c6.20854c","type":"ui_group","name":"Standard","tab":"18e14d4.a4f85b3","order":2,"disp":true,"width":"20","collapse":false},{"id":"18e14d4.a4f85b3","type":"ui_tab","name":"Test","icon":"dashboard","order":9}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [1 March 2021 23:56 UTC](https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808/2 "2021-03-01T23:56:22Z")

</div>

try...

```auto
    <tr ng-repeat="item in msg.payload">
        <td>{{item.value1}}</td>
        <td>{{item.value2}}</td>
        <td>
            <md-button ng-click="send({payload:item})"> click me </md-button>
        </td>
    </tr>

```

↑ this should send the whole item back to node-red (so you can access msg.payload.value1 or msg.payload.value2 etc) (_untested_)

### PS, DONT include `<head>` and `<body>` tags in the ui template (the dashboard provides these)

---

<div class="post-metadata">

**Author:** ![YT2310](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yt2310/32/35255_2.png) [@YT2310](https://discourse.nodered.org/u/YT2310)\
**Post date:** [2 March 2021 07:33 UTC](https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808/3 "2021-03-02T07:33:37Z")

</div>

thank you. this works for me.  
But after clicking the link, you need to reload the table

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 March 2021 07:34 UTC](https://discourse.nodered.org/t/get-different-messages-from-ui-template-while-using-ng-repeat/41808/4 "2021-03-16T07:34:03Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
