Change the color of text in text pallete

I am using two inject nodes and sending 2 string (ON, OFF) values and i am using one function to handle the things in this , when ON value comes i want to change the color and vice versa (based on value the color of text should be changed) .....

Welcome!.
you have not told, where you want the color to change ? i am assuming it is a text node in old dashboard.

https://flows.nodered.org/flow/91bb9ea894340c76796b786e56389b71

Try this.

Its Working fine, if it can be done using template node ??

There are several ways of achieving what you require. this is one of the low code option.
which template node are you referring to ?
image

if you could share the part of flow where you want help, some one can pitch in..

you could also use CSS in combination of function node / ui-template node.

Actually i need in both way

your inputs are not sufficient to help you.

[
{
"id": "55eefbf19b3ed619",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": "",
"env":
},
{
"id": "e123d8757f80775b",
"type": "inject",
"z": "55eefbf19b3ed619",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "cc",
"payload": "ON",
"payloadType": "str",
"x": 310,
"y": 140,
"wires": [
[
"9f1eaf8aa48b3e74"
]
]
},
{
"id": "45a699e656195efd",
"type": "inject",
"z": "55eefbf19b3ed619",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "dd",
"payload": "OFF",
"payloadType": "str",
"x": 310,
"y": 240,
"wires": [
[
"9f1eaf8aa48b3e74"
]
]
},
{
"id": "9f1eaf8aa48b3e74",
"type": "function",
"z": "55eefbf19b3ed619",
"name": "function 4",
"func": "var value = msg.payload;\nvar topic = msg.topic;\n\nif ((topic=="cc")&&(value=="ON")) \n{\n msg.color = "green";\n} \nelse if ((topic=="dd")&&(value=="OFF")) \n{\n msg.color = "red";\n} \nelse\n{\n msg.color = "white";\n}\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": ,
"x": 540,
"y": 180,
"wires": [
[
"8ef4a94dd3f2eecf"
]
]
},
{
"id": "8ef4a94dd3f2eecf",
"type": "template",
"z": "55eefbf19b3ed619",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "This is the payload: {{payload}} !",
"output": "str",
"x": 700,
"y": 180,
"wires": [
[
"cac8d242edc4df1e",
"1c7abd608c1e3ccc"
]
]
},
{
"id": "9d9dd12fb01d13a5",
"type": "ui_template",
"z": "55eefbf19b3ed619",
"name": "",
"order": 0,
"width": 0,
"height": 0,
"format": "<div ng-bind-html="msg.payload">",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 700,
"y": 240,
"wires": [

]
},
{
"id": "cac8d242edc4df1e",
"type": "debug",
"z": "55eefbf19b3ed619",
"name": "debug 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 880,
"y": 200,
"wires":
},
{
"id": "1c7abd608c1e3ccc",
"type": "ui_text",
"z": "55eefbf19b3ed619",
"group": "962bcf7e76f9a8cf",
"order": 4,
"width": 0,
"height": 0,
"name": "",
"label": "text",
"format": "{{msg.payload}}",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 870,
"y": 140,
"wires":
},
{
"id": "962bcf7e76f9a8cf",
"type": "ui_group",
"name": "Default",
"tab": "cd5a125d1165e39c",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "cd5a125d1165e39c",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]

cannot copy your flow. go through this post and repost.

[{"id":"427a1774a227daf7","type":"inject","z":"475994cd586d34e4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":170,"y":330,"wires":[["a87576b797e28225"]]},{"id":"c6777a1ed977cedf","type":"inject","z":"475994cd586d34e4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":170,"y":370,"wires":[["a87576b797e28225"]]},{"id":"57de3798762d996e","type":"function","z":"475994cd586d34e4","name":"magic","func":"if (msg.payload== \"ON\") {\nmsg.payload = \"<span class = 'green'>\" + msg.payload1 + \"</span>\";\n}\nelse if ( (msg.payload == \"OFF\")) {\n        msg.payload = \"<span class = 'red'>\" + msg.payload1 + \" </span>\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":370,"wires":[["afe15dd15328c5d8","fc70b095b429b002"]]},{"id":"afe15dd15328c5d8","type":"debug","z":"475994cd586d34e4","name":"debug 347","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":320,"wires":[]},{"id":"483ba217ac5de561","type":"ui_template","z":"475994cd586d34e4","group":"","name":"CSS","order":13,"width":0,"height":0,"format":"<style>\n    .red {\n        color: red;font-size:30px;\n    }    \n    .green {\n        color: green;font-size:30px;\n    }\n</style>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","className":"","x":170,"y":290,"wires":[[]]},{"id":"a87576b797e28225","type":"template","z":"475994cd586d34e4","name":"","field":"payload1","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":330,"y":370,"wires":[["57de3798762d996e"]]},{"id":"fc70b095b429b002","type":"ui_text","z":"475994cd586d34e4","group":"78cc4be7d68b8793","order":12,"width":"6","height":"1","name":"","label":"","format":"<pre>{{msg.payload}}</pre>","layout":"row-center","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":670,"y":370,"wires":[]},{"id":"78cc4be7d68b8793","type":"ui_group","name":"HEADER","tab":"d90e028674af84a9","order":1,"disp":false,"width":"44","collapse":false,"className":""},{"id":"d90e028674af84a9","type":"ui_tab","name":"LIVE","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

on-off