Try
<div id = "testbutton">
<md-button ng-click = "send({payload: actionX1()})">Test1</md-button>
</div>
<script>
(function(scope) {
//Have to use $watch so we pick up new, incoming msg's
scope.$watch('msg', function(msg) {
const payloadValue = msg.payload
// Do stuff with payloadValue
msg.payload = new Date(payloadValue).toLocaleString('en-GB', { timeZone: 'UTC' })
msg.topic = 'Update'
scope.send(msg)
})
scope.actionX1 = function() {
let rx = 'Test'
return rx
}
})(scope)
</script>
[{"id":"7b2f1e77460fe57f","type":"ui_template","z":"8428164b1645b4b8","group":"3bd9170259dad907","name":"Test Button","order":4,"width":0,"height":0,"format":"<div id = \"testbutton\">\n <md-button ng-click = \"send({payload: actionX1()})\">Test1</md-button>\n</div>\n\n<script>\n (function(scope) {\n //Have to use $watch so we pick up new, incoming msg's\n scope.$watch('msg', function(msg) {\n const payloadValue = msg.payload\n // Do stuff with payloadValue\n\n msg.payload = new Date(payloadValue).toLocaleString('en-GB', { timeZone: 'UTC' })\n msg.topic = 'Update'\n\n scope.send(msg)\n })\n\n scope.actionX1 = function() {\n let rx = 'Test'\n\n return rx\n }\n\n })(scope)\n\n</script>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":2070,"y":800,"wires":[["3b6034a1ca6eedb5"]]},{"id":"6c13eceab34ba03c","type":"inject","z":"8428164b1645b4b8","name":"Test Button Input","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"In","payload":"","payloadType":"date","x":1880,"y":800,"wires":[["7b2f1e77460fe57f"]]},{"id":"3b6034a1ca6eedb5","type":"debug","z":"8428164b1645b4b8","name":"Test Button Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2290,"y":800,"wires":[]},{"id":"3bd9170259dad907","type":"ui_group","name":"Group 1","tab":"562c71ed91742d82","order":1,"disp":true,"width":6},{"id":"562c71ed91742d82","type":"ui_tab","name":"Tab 23","icon":"dashboard","order":23}]