# Template call javascript

**URL:** <https://discourse.nodered.org/t/template-call-javascript/9694>\
**Category:** Dashboard\
**Created:** [2 April 2019 15:24 UTC](https://discourse.nodered.org/t/template-call-javascript/9694 "2019-04-02T15:24:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![accca](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@accca](https://discourse.nodered.org/u/accca)\
**Post date:** [2 April 2019 15:24 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/1 "2019-04-02T15:24:29Z")

</div>

Hi,  
I have this situation:

 ![Cattura](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9b5632a776d0ced3c2635a489de9cd16514bc434.jpeg)

The template node contains a list of link (a href). I want to trigger the same function, but with different parameters. Example:

Link 1: call function('1')  
Link 2: call function('2')

"function" is a function that is located in tags. Is it possible?Because nothing happened...  
The source of template node is:

```auto
<script>
(function() {
function hideShowTab(scope,i) {

            scope.send({payload: {"group":{"hide":["Dashboard_Alarm_zone"],"show":["Dashboard_Dettaglio_RSSI"]},"tagId": scope.msg.payload[0]["tagId"],"timestamp" : ""}});
        }
(function(scope) {
    
       function sendId(id){
           
       }
        scope.$watch('msg.payload', function(newVal, oldVal) {
          
            $( "#alarmList" ).html("<p>Lista allarmi:</p><ul>");
            var date;
            for(var i=(scope.msg.payload[0]["timestamp"].length-1); i>=0;i--){
                console.log("----------"+scope.msg.payload[0]["timestamp"].length);
                date = new Date(scope.msg.payload[0]["timestamp"][i]);
                $( "#alarmList" ).append("<li><a href='javascript:void(0)' ng-click='javascript:sendId("+i+")'>"+date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear()+" "+date.getHours()+":"+(date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes())+"</a></li>");

            }
            $( "#alarmList" ).append("</ul>");
            
        })

    })(scope)
})();
</script>
<div id="alarmList" >
    
    
</div>

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [2 April 2019 23:22 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/2 "2019-04-02T23:22:59Z")

</div>

what is the `console.log(scope.msg.payload)` output ?

---

<div class="post-metadata">

**Author:** ![accca](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@accca](https://discourse.nodered.org/u/accca)\
**Post date:** [3 April 2019 05:55 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/3 "2019-04-03T05:55:34Z")

</div>

I dont know if its important for the problem. Payload comes from the database.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [3 April 2019 05:58 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/4 "2019-04-03T05:58:38Z")

</div>

sure, but the question is, do you see output in the browser console? if not, you have your answer.

---

<div class="post-metadata">

**Author:** ![accca](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@accca](https://discourse.nodered.org/u/accca)\
**Post date:** [3 April 2019 06:15 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/5 "2019-04-03T06:15:57Z")

</div>

Yes...I see the output and my html list is populated correctly

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 April 2019 20:43 UTC](https://discourse.nodered.org/t/template-call-javascript/9694/6 "2019-04-08T20:43:29Z")

</div>

Not sure I've understood the question properly but this may help - it shows how to bind functions to the scope.

> **[Node-RED Dashboard Template Examples (AngularJS)](https://it.knightnet.org.uk/kb/nr-qa/dashboard-template-examples/#a-couple-of-ways-to-send-a-msg-back-to-node-red)**
>
> Some examples of using AngularJS with the Node-RED Dashboard.
> Not all features of Angular are accessible via the Dashboard.
