<button> in 'ui template

I'm using Node-Red 3.1.3. I put the following code in ui_template:

<script>
    function myFunction(mac) {console.log("button click: "+mac); }
</script>

<div ng-repeat="element in msg.payload">
<button onclick="myFunction({{element.mac}})"> </button>
</div>

This causes 'Error: [$compile:nodomevents]'
I also tried the code:

onclick="myFunction('{{element.mac}}')"
onclick="myFunction(element.mac)"

Code from ng-click does not respond to click:
ng-click="myFunction('abc')"

Only this code works:
onclick="myFunction('abc')"

How to properly handle clicking on dynamically created buttons ?

This topic may shed some light HTML Template - use msg.payload
The third example in the ui-template sidebar help text shows how to add the function to the scope.

In ui_tempate, HTML elements such as a button are dynamically created when a message is received. The third example generates a "[ngRepeat:dupes]" error. It only appears once when I click the newly created button.
Solution HTML Template - use msg.payload works OK.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.