gpt4 book ai didi

javascript - 在循环中的仪表板 ui_template (node-red) 中创建复选框并将检查状态分配给输出 msg.payload

转载 作者:行者123 更新时间:2023-12-03 03:32:51 28 4
gpt4 key购买 nike

我正在从初始输入 msg.payload 循环中创建复选框(请参阅下面有效的代码)。传入有效负载的示例:msg.payload=[{"NAME":"a"},{"NAME":"b"}]

<form>
<fieldset style="width:85%">
<legend>choose chartdata</legend>
<div ng-repeat="x in msg.payload">
<input type="checkbox" name={{msg.payload[$index].NAME}}>
<label for={{msg.payload[$index].NAME}}>{{msg.payload[$index].NAME}}</label>
</div>
</fieldset>
</form>

我正在尝试为每个复选框(更改时)获取输出 msg.payload (将被推送到流程),其中包含复选框的名称(此处:“a”或“b”)和状态(选中/未选中)。

有人知道如何做到这一点吗?

附注:流程如下:

[{"id":"3bbd849e.391734","type":"inject","z":"256e6f3d.da9f7","name":"","topic":"","payload":"[{\"NAME\":\"a\"},{\"NAME\":\"b\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"x":341.08331298828125,"y":216.08334350585938,"wires":[["f6bae45e.b99088"]]},{"id":"f6bae45e.b99088","type":"ui_template","z":"256e6f3d.da9f7","group":"34890ec3.1f4b6a","name":"checkbox","order":11,"width":"3","height":"8","format":"<form>\n    <fieldset style=\"width:85%\">\n    <legend>choose chartdata</legend>\n        <div ng-repeat=\"x in msg.payload\">\n            <input type=\"checkbox\" name={{msg.payload[$index].NAME}}>\n            <label for={{msg.payload[$index].NAME}}>{{msg.payload[$index].NAME}}</label>\n        </div>\n    </fieldset>\n</form>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":513.4889526367188,"y":217.39315795898438,"wires":[[]]},{"id":"34890ec3.1f4b6a","type":"ui_group","name":"Group 1","tab":"a52427c4.c3901","order":1,"disp":true,"width":6},{"id":"a52427c4.c3901","type":"ui_tab","z":"","name":"test","icon":"dashboard","order":12}]

最佳答案

这段代码似乎有效:

<form>
<fieldset style="width:85%">
<legend>choose chartdata</legend>
<div ng-repeat="x in msg.payload">
<label>{{x.NAME}}
<input type="checkbox" style="float:left; position: relative; top: 5px;"
ng-model="check"
ng-change="send({var:x.NAME, state:check})">
</label>
</div>
</fieldset>
</form>

取消选中“传递来自输入的消息”。和“将输出消息添加到存储状态”。在 ui_template 中

关于javascript - 在循环中的仪表板 ui_template (node-red) 中创建复选框并将检查状态分配给输出 msg.payload,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46008118/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com