Ng-style with or condition

Tags: #<Tag:0x00007f2fbdae4d38> #<Tag:0x00007f2fbdae4220>

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!