WOPR
(A. R.)
September 8, 2019, 5:09pm
1
Hey,
I’m struggeling with an ng-style expression and two possible conditions within an or operator:
The text color should change when one contact changes.
I tried different solutions, looked at stackoverflow, but openhab only recognizes the first condition (kontakt1
). My tried solutions are:
<div ng-style="{color: itemState('kontakt1')=='CLOSED' ? 'green' : 'red' || itemState('kontakt2')=='CLOSED' ? 'green' : 'red' }">Büro</div>
<div ng-style="{color: (itemState('kontakt1')=='CLOSED' || itemState('kontakt2')=='CLOSED') ? 'green' : 'red' }">Büro</div>
Any hints?
Kind regards
ysc
(Yannick Schaus)
September 8, 2019, 11:59pm
2
Your 2nd syntax should work:
<div ng-style="{ color: ('a'=='a' || 'a'=='b') ? 'green' : 'red' }">Should be green</div>
<div ng-style="{ color: ('a'=='b' || 'a'=='a') ? 'green' : 'red' }">Should be green</div>
<div ng-style="{ color: ('a'=='b' || 'a'=='c') ? 'green' : 'red' }">Should be red</div>
1 Like
WOPR
(A. R.)
September 10, 2019, 7:16pm
3
Works now! I forgot to switch 'green'
and 'red'
.
Thank you!
NCO
(E. Gerland)
April 23, 2020, 6:14am
4
Is this also possible with something like “contains”
So, to be just true if a string item contains a string?
NCO
(E. Gerland)
April 23, 2020, 9:55am
5
These do not work:
Does NOT work:
<div style="background-color: {{itemValue('CalName8')| "Tom:.*" ? 'yellow' : 'blue'}}">
Does NOT work:
<div style="background-color: {{itemValue('CalName8')| pattern="Tom:*" ? 'yellow' : 'blue'}}">
Does NOT work:
<div style="background-color: {{itemValue('CalName8').match("Tom:")!= null ? 'yellow' : 'blue'}}">