Fellow ui-template pro's,
I'm using ui-template to setup a table displaying the content of an incoming message containing an array of objects. With ng-repeat I can create the html table, add and label buttons and checkboxes. I want the buttons to work as a toggle, therefore need it to send the current state and an ID info like:
<button name="activate"
ng-click="send({'schedule':{{msg.schedules[$index].ID}}, 'active': {{msg.schedules[$index].active}}, 'once': {{msg.schedules[$index].once}} })"
>{{msg.schedules[$index].button}}</button>
Now, while the labelling works with the {{}} notation, the button fails to send anything. At the same time, an sends the exact same message correctly on ng-change:
<input
type="checkbox"
id="once"
name="activate"
ng-checked="{{msg.schedules[$index].once}}"
ng-model="check1"
ng-change="send({'schedule':{{msg.schedules[$index].ID}}, 'active': {{msg.schedules[$index].active}}, 'once': {{msg.schedules[$index].once}} })"
> once
Any ideas as to why that's not working or why the is, would be extremely appreciated.
Clemens
example flow:
[
{
"id": "ad7a80fa64d29e50",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "dbbf35627f50c7fe",
"type": "inject",
"z": "ad7a80fa64d29e50",
"name": "",
"props": [
{
"p": "schedules",
"v": "[{\"ID\":1,\"Name\":\"morning\",\"lastRun\":null,\"repetition\":1,\"nextRun\":null,\"active\":0,\"once\":1,\"button\":\"once\"},{\"ID\":2,\"Name\":\"early\",\"lastRun\":null,\"repetition\":1,\"nextRun\":null,\"active\":0,\"once\":1,\"button\":\"once\"},{\"ID\":3,\"Name\":\"late\",\"lastRun\":null,\"repetition\":1,\"nextRun\":null,\"active\":0,\"once\":0,\"button\":\"off\"}]",
"vt": "json"
},
{
"p": "schedulesArray",
"v": "[[{\"slot\":\"05:00:00\",\"displayText\":\" 05:00:00\"},{\"Relay\":\"Relay1\",\"displayText\":\" Relay1\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"05:30:00\",\"displayText\":\" 05:30:00\"},{\"Relay\":\"Relay2\",\"displayText\":\" Relay2\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"06:00:00\",\"displayText\":\" 06:00:00\"},{\"Relay\":\"Relay5\",\"displayText\":\" Relay5\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"06:30:00\",\"displayText\":\" 06:30:00\"},{\"Relay\":\"Relay6\",\"displayText\":\" Relay6\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"07:00:00\",\"displayText\":\" 07:00:00\"},{\"Relay\":\"Relay4\",\"displayText\":\" Relay4\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"07:30:00\",\"displayText\":\" 07:30:00\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"08:00:00\",\"displayText\":\" 08:00:00\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"08:30:00\",\"displayText\":\" 08:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay2\",\"displayText\":\" Relay2\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"09:00:00\",\"displayText\":\" 09:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay4\",\"displayText\":\" Relay4\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"09:30:00\",\"displayText\":\" 09:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay1\",\"displayText\":\" Relay1\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"10:00:00\",\"displayText\":\" 10:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay5\",\"displayText\":\" Relay5\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"10:30:00\",\"displayText\":\" 10:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay6\",\"displayText\":\" Relay6\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"11:00:00\",\"displayText\":\" 11:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"11:30:00\",\"displayText\":\" 11:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightSkyBlue\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"12:00:00\",\"displayText\":\" 12:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"12:30:00\",\"displayText\":\" 12:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"13:00:00\",\"displayText\":\" 13:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"13:30:00\",\"displayText\":\" 13:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"14:00:00\",\"displayText\":\" 14:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"14:30:00\",\"displayText\":\" 14:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"15:00:00\",\"displayText\":\" 15:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"15:30:00\",\"displayText\":\" 15:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay4\",\"displayText\":\" Relay4\",\"backgroundcolor\":\"LightGray\"}],[{\"slot\":\"16:00:00\",\"displayText\":\" 16:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightGray\"}],[{\"slot\":\"16:30:00\",\"displayText\":\" 16:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"Relay3\",\"displayText\":\" Relay3\",\"backgroundcolor\":\"LightGray\"}],[{\"slot\":\"17:00:00\",\"displayText\":\" 17:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"17:30:00\",\"displayText\":\" 17:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"18:00:00\",\"displayText\":\" 18:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"18:30:00\",\"displayText\":\" 18:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"19:00:00\",\"displayText\":\" 19:00:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}],[{\"slot\":\"19:30:00\",\"displayText\":\" 19:30:00\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"},{\"Relay\":\"\",\"displayText\":\"...\",\"backgroundcolor\":\"white\"}]]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"x": 270,
"y": 300,
"wires": [
[
"628af32b557d2b10"
]
]
},
{
"id": "628af32b557d2b10",
"type": "ui_template",
"z": "ad7a80fa64d29e50",
"group": "641b924c56253216",
"name": "",
"order": 1,
"width": 16,
"height": 9,
"format": "<style>\n table, th, td {\n border: 1px solid black;\n border-collapse: collapse;\n }\n td {\n text-align: center;\n width: 300px;\n \n }\n}\n</style>\n\n<table class=\"table\" style=\"height:500px\">\n <tr style=\"height:50px\">\n <td></td>\n <td ng-repeat=\"sched in msg.schedules\">\n <p>{{msg.schedules[$index].Name}}</p>\n <p>repeats every: {{msg.schedules[$index].repetition}} d</p>\n <button\n name=\"activate\" \n ng-click=\"send({'schedule':{{msg.schedules[$index].ID}}, 'active': {{msg.schedules[$index].active}}, 'once': {{msg.schedules[$index].once}} })\"\n >{{msg.schedules[$index].button}}</button>\n <input \n type=\"checkbox\"\n id=\"once\"\n name=\"activate\" \n ng-checked=\"{{msg.schedules[$index].once}}\" \n ng-model=\"check1\" \n ng-change=\"send({'schedule':{{msg.schedules[$index].ID}}, 'active': {{msg.schedules[$index].active}}, 'once': {{msg.schedules[$index].once}} })\"\n > once\n\n </td>\n </tr>\n\n <tr style=\"height:30px\" ng-repeat=\"tableRow in msg.schedulesArray\">\n <td ng-repeat=\"cell in tableRow\" style=\"background-color:{{msg.schedulesArray[$parent.$index][$index].backgroundcolor }}\">\n {{ msg.schedulesArray[$parent.$index][$index].displayText }}\n </td>\n </tr>\n\n</table>\n",
"storeOutMessages": true,
"fwdInMessages": false,
"resendOnRefresh": false,
"templateScope": "local",
"className": "",
"x": 420,
"y": 300,
"wires": [
[
"f6189e4141467829"
]
]
},
{
"id": "f6189e4141467829",
"type": "debug",
"z": "ad7a80fa64d29e50",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 570,
"y": 300,
"wires": []
},
{
"id": "641b924c56253216",
"type": "ui_group",
"name": "Default",
"tab": "6e645f72d3aaf94d",
"order": 1,
"disp": true,
"width": "21",
"collapse": false,
"className": ""
},
{
"id": "6e645f72d3aaf94d",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]