Ng-click send values


when i click at button1, i found that msg.archive take value 10, but, when i click at button2 msg.archive return undefined.
can anyone explain me why ? and how can i keep the value of each button ??
And thank you.

  <button class="inner" id="mBtn1" ng-click="send({archive: '10'})">button1</button>
  <button class="inner" id="mBtn2" ng-click="send({cookies: 1})">button2</button>


Well, with Button2 you send {cookies: 1} so there is no archive field in that object so it's correct to be undefined. If you want to have both fields always returned then create external variable {archive: '', cookies: 0}, update it with the button and then send that object.

1 Like


thanks for reply it gives ideas,... but, what i really want is to send each value send each value separately. when i click on button2 cookies will not change it value.



I don't think I follow.
In the first post you said that button2 returns msg.archive as undefined, which is correct looking at the code (button2 returns only msg.cookie). But in your second post you mention that you want to send each value separately which is what you already do in your code.

Maybe write what result you want to have in the end? {archive: some_value_1, cookies: some_value_2} or something else?

1 Like


my first code doesn't send value separately. when i click at button1 cookie = 1, but when i click at button2 cookie become undefined. i need cookie to be set at 1 ..
you may test it, perhaps you will understant what i need.



Ok, so you must do what I wrote in my first post.
You can also use join node like this:

[{"id":"a05cd8aa.364e68","type":"ui_template","z":"e9bac780.ed1af8","group":"f9739ca5.a36ef","name":"","order":0,"width":0,"height":0,"format":"<button class=\"inner\" id=\"mBtn1\" ng-click=\"send({archive: '10'})\">button1</button>\n<button class=\"inner\" id=\"mBtn2\" ng-click=\"send({cookies: 1})\">button2</button>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":680,"y":140,"wires":[["448460c7.88a028"]]},{"id":"448460c7.88a028","type":"join","z":"e9bac780.ed1af8","name":"","mode":"custom","build":"merged","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","x":890,"y":140,"wires":[["ddd3646.1d1d418"]]},{"id":"ddd3646.1d1d418","type":"debug","z":"e9bac780.ed1af8","name":"","active":true,"console":"false","complete":"false","x":1100,"y":140,"wires":[]},{"id":"f9739ca5.a36ef","type":"ui_group","z":"","name":"Pogoda","tab":"8e345031.920048","order":2,"disp":true,"width":"6"},{"id":"8e345031.920048","type":"ui_tab","z":"","name":"test","icon":"dashboard","order":1}]


When you send({key:value)} it creates a new message instead of send(msg), which references the msg scope that you can change for example:

<button class="inner"  id="mBtn1" ng-click="msg.archive = '10';send(msg)">button1</button>
<button class="inner"  id="mBtn2" ng-click="msg.cookies = 1;send(msg)">button2</button>