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

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";}

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

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

It would be easier if you posted the flow

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!!!

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

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

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:

<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:

<script>

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

thank you very very much. it works perfectly.:blush::ok_hand:

1 Like

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 ???

1 Like

"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:
<div ng-if="msg.topic == 1" ng-class="{display: none}">
<div ng-if="msg.topic == 2" ng-class="{display: block}">
1 Like

ok thanks for replying. you are absolutly right

1 Like