Help with Angular HTML

I have a simple table which has a list of errors. I almost have what I'm looking for except that I do not know how to return something correctly. What I'd like to accomplish here is to return an index of the row selected from ng-click to the output of the HTML template.

The table highlights the row and click sets the template output.

The ng-click is not sending any values to the output message except "socketid" and "_msgid".

  1. How can I get a value to the output message
  2. How do I reference the index of the selected row from the table.

Please help.
Thanks.

image

<script>
var value = "TEST";
this.scope.action =function(){return value:}
</script>
<style>
    {{msg.style}}
</style>

<table>
  <tr><td>{{msg.col1_header}}</td><td>{{msg.col2_header}}</td></tr>
  <tr ng-repeat="obj in msg.payload" ng-click ="send({payload:action()})">

    <td width="1%">{{ obj.name || obj.First}}</td>
    <td width="99%">{{ obj.ip || obj.Last }}</td>

  </tr>
</table>
~~~

Try

<script>
this.scope.action = function(value){return value}
</script>
<style>
    {{msg.style}}
</style>

<table>
  <tr><td>{{msg.col1_header}}</td><td>{{msg.col2_header}}</td></tr>
  <tr ng-repeat="obj in msg.payload" ng-click ="send({payload:action($index)})">

    <td width="1%">{{ obj.name || obj.First}}</td>
    <td width="99%">{{ obj.ip || obj.Last }}</td>

  </tr>
</table>

Also de-select pass-through and add output message to stored state.
Example flow

[{"id":"bb393ea0830a192d","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"ip\":1,\"name\":\"aa\"},{\"ip\":2,\"name\":\"bb\"}]","payloadType":"json","x":70,"y":4660,"wires":[["50612d14c11665d9"]]},{"id":"50612d14c11665d9","type":"ui_template","z":"452103ea51141731","group":"2d4fe667.28f8ba","name":"","order":17,"width":0,"height":0,"format":"<script>\nthis.scope.action = function(value){return value}\n</script>\n<style>\n    {{msg.style}}\n</style>\n\n<table>\n  <tr><td>{{msg.col1_header}}</td><td>{{msg.col2_header}}</td></tr>\n  <tr ng-repeat=\"obj in msg.payload\" ng-click =\"send({payload:action($index)})\">\n\n    <td width=\"1%\">{{ obj.name || obj.First}}</td>\n    <td width=\"99%\">{{ obj.ip || obj.Last }}</td>\n\n  </tr>\n</table>\n~~~","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":300,"y":4660,"wires":[["e2fe93020cc45980"]]},{"id":"e2fe93020cc45980","type":"debug","z":"452103ea51141731","name":"debug 111","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":4640,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Still Nothing on the output message from template.

Thanks for the advice on $index passing it to the function and then back.

I tried this and I'm still not getting anything in the message payload from the template node still. I only get socketid and _msgid. This script works well with another template node that's why I input the "TEST" value hard coded.

Kind Regards,

Working fine here

You had a typo in your OG script : after value.
does my example flow work for you?

AH HA!
I'm half blind. I was totally looking at this colon and seeing semi-colon.

No script errors in the template!

Thanks MUCH. Wasted a lot of time scratching my head on this one.

I got it all working thanks to the expert advice and checking my code. The list is clickable to reference the array that is in a flow context variable(s). Using the index to send the error to a notification OK/Cancel. If OK, then remove the item from the array and log the acknowledged error and update the list showing the remainder of the list.

1 Like

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