s.simma
(siegi simma)
September 28, 2016, 2:40pm
1
@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 ?
ysc
(Yannick Schaus)
September 28, 2016, 6:41pm
2
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.
s.simma
(siegi simma)
September 28, 2016, 8:53pm
3
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
ysc
(Yannick Schaus)
September 28, 2016, 9:19pm
4
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
s.simma
(siegi simma)
September 29, 2016, 5:02am
5
@ysc
This solves the problem. Thank’s a lot !