# Put the key of a object in ng-repeat to a button's ng-click to send the key as part of a msg

**URL:** <https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [9 March 2022 19:22 UTC](https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614 "2022-03-09T19:22:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thematrixrearwindow](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@thematrixrearwindow](https://discourse.nodered.org/u/thematrixrearwindow)\
**Post date:** [9 March 2022 19:22 UTC](https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614/1 "2022-03-09T19:22:32Z")

</div>

Hi there,

how can i get the key of the (key, value) to a button to send it as msg.payload in ng-click?  
In this part i want to insert the {{key}} from the ng-repeat but that doesn't seem to work.

```auto
<md-button ng-click="msg.payload = {{key}}; send(msg);">SAVE</md-button>

```

Complete ui template code:

```auto
<div ng-repeat="(key, value) in msg.payload">
    <div ng-if="value > 0">
        <p ng-style="{'background-color':'green'}">
            {{key}}: {{value}}
        </p>
        <div>
             <md-button ng-click="msg.payload = {{key}}; send(msg);">SAVE</md-button>
        </div>
    </div>
</div>

```

Thanks!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 March 2022 19:35 UTC](https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614/2 "2022-03-09T19:35:39Z")

</div>

```auto
<div ng-repeat="(key, val) in msg.payload">
    <div ng-if="val > 0">
        <p ng-style="{'background-color':'green'}">
            {{key}}: {{val}}
        </p>
        <div>
            <md-button ng-click="send({topic: key, payload: val});">SAVE</md-button>
        </div>
    </div>
</div>

```

REF: [AngularJS Tutorial =\> ngRepeat](https://riptutorial.com/angularjs/example/6271/ngrepeat#:~:text=ng%2Drepeat%20is%20a%20built,each%20item%20in%20the%20collection.&text=To%20repeat%20multiple%20DOM%20elements,ng%2Drepeat%2Dend%20directives).

---

<div class="post-metadata">

**Author:** ![thematrixrearwindow](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@thematrixrearwindow](https://discourse.nodered.org/u/thematrixrearwindow)\
**Post date:** [9 March 2022 19:49 UTC](https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614/3 "2022-03-09T19:49:11Z")

</div>

Thank you! That's it 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 March 2022 19:49 UTC](https://discourse.nodered.org/t/put-the-key-of-a-object-in-ng-repeat-to-a-buttons-ng-click-to-send-the-key-as-part-of-a-msg/59614/4 "2022-03-23T19:49:56Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
