i use node-red.js with the normal ui-dashboard. I have a signal 1/0 and i want to display it on the Dashboard as a green box (signal 1) or a red box (signal 0) So i take the template node with this code:
<canvas id="myCanvas" width="15px" height="15px" style="background-color:yellow"/>
<script language="javascript" type="text/javascript">
if("msg.payload" == 1)
{
document.getElementById("myCanvas").style.background = "green";
}
else {
document.getElementById("myCanvas").style.background = "red";
}
</script>
With the Debugger i see, that the payload isr correct, but it doesn´t work. The box is red, however the signal is.
So i used "window.alter(msg.payload)" and in the browser appears the window with "undefinied".. I already put the "JSON"Node between the inject-node and the template-node
I already used this code:
<div id="ngDiv" ng-bind-html="msg.payload"></div>
<canvas id="myCanvas" width="15px" height="15px" style="background-color:yellow"/>
<script language="javascript" type="text/javascript">
if(document.getElementById("ngDiv").getAttribute("ng-bind-html") == 1)
{
document.getElementById("myCanvas").style.background = "green";
}
else {
document.getElementById("myCanvas").style.background = "red";
}
</script>
But it doesn´t work too... I hope you can help me!
Thanks KiweX
via kiwex
No comments:
Post a Comment