I need a set of dynamic buttons, each button will have a name from a msg input array. Clicking any button will provide an output of that button's name. The names and number of buttons will be dynamic based on the input array of names.
I am using the ui_template node to build buttons. This part works. I need help to fix the code to output the button's name when clicked.
Here is my test flow so far:
[
{
"id": "cd92469bacae86bb",
"type": "inject",
"z": "4e84556f7bdfde3f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"Alan\",\"Gaye\",\"Fred\"]",
"payloadType": "json",
"x": 860,
"y": 1340,
"wires": [
[
"c910ae5a503fa8a9"
]
]
},
{
"id": "c910ae5a503fa8a9",
"type": "ui_template",
"z": "4e84556f7bdfde3f",
"group": "f9fbe54339c329ea",
"name": "",
"order": 1,
"width": "6",
"height": "1",
"format": "\n\n<div>\n <button ng-repeat=\"name in msg.payload\" ng-click=\"sendName(name)\">{{name}}</button>\n</div>\n\n<script>\n (function(scope) {\n scope.sendName = function(name) {\n var message = {\n payload: name\n };\n return message;\n };\n })(scope);\n</script>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 1140,
"y": 1340,
"wires": [
[
"2556190649c2e7ee"
]
]
},
{
"id": "2556190649c2e7ee",
"type": "debug",
"z": "4e84556f7bdfde3f",
"name": "debug 333",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1330,
"y": 1340,
"wires": []
},
{
"id": "f9fbe54339c329ea",
"type": "ui_group",
"name": "Group 1",
"tab": "c7c16878223e2d99",
"order": 1,
"disp": true,
"width": 6
},
{
"id": "c7c16878223e2d99",
"type": "ui_tab",
"name": "Test Dashboard",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
Alan