Ng-style with or condition

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

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

Works now! I forgot to switch 'green' and 'red'.

Thank you!

Is this also possible with something like “contains”
So, to be just true if a string item contains a string?

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'}}">