# Send variable from dashboard template node to another one, other than msg.payload

**URL:** <https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501>\
**Category:** General\
**Created:** [5 December 2018 13:46 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501 "2018-12-05T13:46:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [5 December 2018 13:46 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/1 "2018-12-05T13:46:06Z")

</div>

is it possible to send a variable other then msg.payload and test on it on the other template.  
i test this example but it doesn't work for me.!!  
template1 :  
`<button class="inner" id="myBtn1" ng-click="send({topic: '1'})">Archive</button>`  
template 2:

> ```
> <div id="myarchive" class="archive">
> <tr ng-repeat="file in msg.payload | orderBy:sortType:sortReverse| filter:search track by $index" style="width:100%" flex>
> {{file}}
> </td>
> </tr>
> </div>
> var archive = document.getElementById('myarchive');
> if(msg.topic == "1")
> {archive.style.display = "block";}
> 
> ```

---

<div class="post-metadata">

**Author:** ![JayGhb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jayghb/32/5550_2.png) [@JayGhb](https://discourse.nodered.org/u/JayGhb)\
**Post date:** [5 December 2018 14:07 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/2 "2018-12-05T14:07:33Z")

</div>

> [@hathemi](#):
>
> ```auto
> var archive = document.getElementById('myarchive');
> if(msg.topic == "1")
> {archive.style.display = "block";}
> 
> ```

I did not test this part, sorry if my answer is "stupid" but shouldn't it be between \<script\> \</script\> tags, to work?

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [5 December 2018 14:09 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/4 "2018-12-05T14:09:20Z")

</div>

yes it is between `<script> </script>` tags.

---

<div class="post-metadata">

**Author:** ![JayGhb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jayghb/32/5550_2.png) [@JayGhb](https://discourse.nodered.org/u/JayGhb)\
**Post date:** [5 December 2018 14:38 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/5 "2018-12-05T14:38:31Z")

</div>

It would be easier if you posted the flow

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [5 December 2018 14:43 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/6 "2018-12-05T14:43:26Z")

</div>

sorry i can't' post the flow ... i think the problem is in tag, still looking if i can test {{msg.topic}} like this or not!!!

---

<div class="post-metadata">

**Author:** ![JayGhb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jayghb/32/5550_2.png) [@JayGhb](https://discourse.nodered.org/u/JayGhb)\
**Post date:** [5 December 2018 14:47 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/7 "2018-12-05T14:47:06Z")

</div>

Okay if you can't. But anyway, to access msg properties in template node just {{topic}} is enough because of the Mustache format. See the template node info for more

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [5 December 2018 14:59 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/8 "2018-12-05T14:59:50Z")

</div>

i'm not using function template. i'am using dashboard template.

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [5 December 2018 15:04 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/9 "2018-12-05T15:04:24Z")

</div>

It might be best if you share your flow. If your button only outputs a topic, your 2nd template will not receive a msg.payload.

Your html was missing a few tags and you could do it multiple ways either with ng-if and ng-class:

```auto
<div ng-if="msg.topic == 1" ng-class="{display: block}">
    <table>
        <tr ng-repeat="file in msg.payload | orderBy:sortType:sortReverse| filter:search track by $index" style="width:100%" flex>
                <td>{{file}}</td>
         </tr>
    </table>
</div>
<div ng-if="msg.topic == 2" ng-class="{display: inline}">
    <table>
        <tr ng-repeat="file in msg.payload | orderBy:sortType:sortReverse| filter:search track by $index" style="width:100%" flex>
                <td>{{file}}</td>
         </tr>
    </table>
</div>

```

Or via script you'll need to access the Angular scope to access your msg.topic like such:

```auto
<script>

(function($scope) {
var archive = document.getElementById('myarchive');
    $scope.$watch('msg', function() {
       if ($scope.msg.topic === 1){
         archive.style.display = "block";
       }
    }
})(scope);
</script>

```

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [5 December 2018 16:00 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/11 "2018-12-05T16:00:36Z")

</div>

thank you very very much. it works perfectly.😊👌

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [6 December 2018 11:03 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/12 "2018-12-06T11:03:46Z")

</div>

ok, now i want to hide that section by double clicking on button  
i make this  
`<button class="inner" id="myBtn1" ng-click="send({topic: '1'})" ng-dblclick="send({topic: '2'})">Archive</button></div>`

then  
i repeat the same

 tags like this

`<div ng-else-if="msg.topic == 2" ng-class="{display: none}">`  
but it doesn' work, Am i missing something ???

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [6 December 2018 18:28 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/13 "2018-12-06T18:28:50Z")

</div>

"ng-else-if" doesn't exist. "ng-if" evaluates the expression and if true will display the element otherwise it won't show. So you might want to have twice your

, once for each case:

```auto
<div ng-if="msg.topic == 1" ng-class="{display: none}">
<div ng-if="msg.topic == 2" ng-class="{display: block}">
```

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [6 December 2018 19:33 UTC](https://discourse.nodered.org/t/send-variable-from-dashboard-template-node-to-another-one-other-than-msg-payload/5501/14 "2018-12-06T19:33:20Z")

</div>

ok thanks for replying. you are absolutly right
