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


#1

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

#2

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


#4

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


#5

It would be easier if you posted the flow


#6

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


#7

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


#8

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


#9

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>

#11

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


#12

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


#13

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

#14

ok thanks for replying. you are absolutly right