# Ontouchstart / ng-Touchstart / UI-template

**URL:** https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632
**Category:** Dashboard
**Created:** [7 November 2018 08:13 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632 "2018-11-07T08:13:05Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![BastianG](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BastianG](https://discourse.nodered.org/u/BastianG)
#### Post date: [7 November 2018 08:13 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/1 "2018-11-07T08:13:05Z")

</div>

Hello Guys.

I'm new in the node red game.  
I'm currently have problems with an angular js directive. I tried to install and make ngtouch work, but without luck.  
I also tried angular-gestures, no luck eighter.

Then i managed to get ontouchstart to fire a function when clicking a md-button. The problem is that ontouchstart is not a angularjs directive, thus it will not update my callback function and send a new msg.payload.

I would like to send 1 or 0 as my payload message. touchstart should send 0, and touch end should send 1. How do i fix this?

Here is what i have so far.

```
<md-button
ontouchstart="send({payload:mdown()})"
ontouchend="send({payload:mup()})">
</md-button>

<script>
var value = "hello world";
this.scope.mdown = function() { return "0" }
this.scope.mup = function() { return "1" }
</script>

```

I really need some help here.

Best Regards

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [7 November 2018 08:59 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/2 "2018-11-07T08:59:19Z")

</div>

ngTouch is already built in but only adds swipe left and swipe right. ngClick handles the basic click and touch.

---

<div class="post-metadata">

### Author: ![BastianG](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BastianG](https://discourse.nodered.org/u/BastianG)
#### Post date: [7 November 2018 12:28 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/5 "2018-11-07T12:28:21Z")

</div>

> [@BastianG](#):
>
> But i need a ngTouchstart + ngtouchend, or touchpressed? How do i do that?

But i need a ngTouchstart + ngtouchend, or touchpressed? How do i do that?

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [7 November 2018 12:42 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/6 "2018-11-07T12:42:58Z")

</div>

Please don't "bump" the thread every two hours. If someone knows the answer when they read the forum they will post an answer

---

<div class="post-metadata">

### Author: ![BastianG](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BastianG](https://discourse.nodered.org/u/BastianG)
#### Post date: [8 November 2018 13:25 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/7 "2018-11-08T13:25:43Z")

</div>

I managed to find a way around the problem. I used jQuery to "simulate" mousedown and mouseup. Now it works.

---

<div class="post-metadata">

### Author: ![logen563](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@logen563](https://discourse.nodered.org/u/logen563)
#### Post date: [10 November 2018 15:48 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/8 "2018-11-10T15:48:45Z")

</div>

hello!  
Can I have the answear? I have the same problem..

---

<div class="post-metadata">

### Author: ![martinschki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/martinschki/32/737_2.png) [@martinschki](https://discourse.nodered.org/u/martinschki)
#### Post date: [15 November 2018 17:55 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/9 "2018-11-15T17:55:50Z")

</div>

+1  
could you please share your solution?

---

<div class="post-metadata">

### Author: ![deepsouth](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@deepsouth](https://discourse.nodered.org/u/deepsouth)
#### Post date: [26 January 2019 11:25 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/10 "2019-01-26T11:25:32Z")

</div>

Really keen to know the answer here - I have the same frustrating problem

My similar code issue is below which passes the a string to the exec node on the RPI when the button is pressed, and when it is released..:

```
<script>
    this.scope.mdown = function() { return "python /home/pi/....turn something on"; }
    this.scope.mup = function() { return "python /home/pi/....turn something off"; }
</script>
<md-button 
    ng-touchend = "send({payload:mup()})"
    ng-touchstart = "send({payload:mdown()})"
>
My Action Button
</md-button>
```

---

<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: [26 January 2019 17:22 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/11 "2019-01-26T17:22:06Z")

</div>

Try the following solution: [Momentary button on Dashboard](https://discourse.nodered.org/t/momentary-button-on-dashboard/4906/5?u=hugobox)

---

<div class="post-metadata">

### Author: ![deepsouth](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@deepsouth](https://discourse.nodered.org/u/deepsouth)
#### Post date: [26 January 2019 19:14 UTC](https://discourse.nodered.org/t/ontouchstart-ng-touchstart-ui-template/4632/12 "2019-01-26T19:14:01Z")

</div>

😀 worked very well! Thank you!
