# Ng-click send values

**URL:** <https://discourse.nodered.org/t/ng-click-send-values/5636>\
**Category:** General\
**Created:** [10 December 2018 11:21 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636 "2018-12-10T11:21:35Z")\
**Posts on this page:** 7\
**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:** [10 December 2018 11:21 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/1 "2018-12-10T11:21:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marooned](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marooned/32/2858_2.png) [@Marooned](https://discourse.nodered.org/u/Marooned)\
**Post date:** [10 December 2018 12:09 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/2 "2018-12-10T12:09:07Z")

</div>

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.

---

<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:** [10 December 2018 13:08 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/3 "2018-12-10T13:08:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marooned](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marooned/32/2858_2.png) [@Marooned](https://discourse.nodered.org/u/Marooned)\
**Post date:** [10 December 2018 14:29 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/4 "2018-12-10T14:29:13Z")

</div>

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?

---

<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:** [10 December 2018 14:35 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/5 "2018-12-10T14:35:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marooned](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marooned/32/2858_2.png) [@Marooned](https://discourse.nodered.org/u/Marooned)\
**Post date:** [10 December 2018 14:46 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/6 "2018-12-10T14:46:25Z")

</div>

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

```auto
[{"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}]

```

---

<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:** [10 December 2018 14:48 UTC](https://discourse.nodered.org/t/ng-click-send-values/5636/7 "2018-12-10T14:48:46Z")

</div>

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:

```auto
<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>
```
