Question regarding templates

@ysc
Is it possible to use a templete like this and change the value “HK1Korrektur” on click:

<button style="width: 100%; height: 2.6em;
  border: 0; color: white; background: midnightblue;
  font-size: 20px"
  ng-click="sendCmd('HK1Korrektur', 'HK1Korrektur'  + 0.5)">
  <i class="glyphicon glyphicon-menu-up"></i>
</button>

<center>Korrektur</center>
<center><span style="color: cyan; font-size: 18pt">{{'%.1f' | sprintf:itemValue('HK1Korrektur')}}°C</span></center>

<button style="width: 100%; height: 2.6em;
  border: 0; color: white; background: midnightblue;
  font-size: 20px" 
  ng-click="sendCmd('HK1Korrektur', 'HK1Korrektur'  - 0.5)">
  <i class="glyphicon glyphicon-menu-down"></i>
</button>

This code line doesn’t work…
ng-click=“sendCmd(‘HK1Korrektur’, ??? HK1Korrektur + 0.5 ???)”>

Is there a simple way do this ?

You’re trying to increment a string literal instead of the actual value.

Try:
sendCmd('HK1Korrektur', parseFloat(itemValue('HK1Korrektur')) + 0.5)

the parseFloat part might not be necessary if your value is already a decimal number but it doesn’t hurt.

Thanks for your help,
but it seems if there is a function in the “sendCmd” it doesn’t work at all.

HK1Korrektur = 0.4
after click "UP"
sendCmd(‘HK1Korrektur’, parseFloat(itemValue(‘HK1Korrektur’)) + 0.5) shows 0.5
sendCmd(‘HK1Korrektur’, itemValue(‘HK1Korrektur’) + 0.5) shows 0.4
sendCmd(‘HK1Korrektur’, 0.4 + 0.5) shows 0.9

Damn, you’re right… I’ll add a few functions to allow parseInt and parseFloat in expressions, but in the meantime, you can use this dirty hack:
itemValue('HK1Korrektur') * 1 + 0.5
the multiplication by 1 performs the cast :slight_smile:

@ysc
This solves the problem. Thank’s a lot !