简体   繁体   中英

template in Node-RED

I would recuperate the value of a variable in the template node. The value of this variable is calculated in a function node.

在此处输入图片说明

The way to pass your array out of the function node, so it can be used inside the ui_template node, is to return it as the payload -- like so:

var array = [12, 34, 56]; // or whatever
msg.payload = array;
return msg;

In your ui_template code, you can then use the Angular ng-repeat directive to iterate over the payload array -- for example, to put them into a simple 1-column table:

<table>
    <tr ng-repeat="value in msg.payload">
        <td>{{value}}</td>
    </tr>
</table>

But, if your goal is to plot them on a line or bar chart, it would be far easier to use the built-in dashboard ui_chart node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM