<button> in 'ui template

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

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

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

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


Code from ng-click does not respond to click:

Only this code works:

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.