<div *ngFor="let f of layout?.photoframes; let i = index" [attr.data-index]="i">
<input type="number" [(ngModel)]="f.x" [style.border-color]="(selectedObject===f) ? 'red'" />
</div>
the conditional style throws the error
Conditional expression (selectedObject===f) ? 'red' requires all 3 expressions at the end of the expression [(selectedObject===f) ? 'red'] what can I do?
A conditional expression if el then e2 else e3 fi evaluates to the current value of the expression e2 if the current (Boolean) value of the expression el is true, and the current value of the expression e3 otherwise.
You need also to pass the result of the case in which condition will return false
. In other words you need to pass correct ternary operator
Something like if/else
. If true
return red
, else return blue
.
(selectedObject === f) ? 'red' : 'blue'
This applies to a different context, but if you are using a pipe ( | ) in Angular and you get this error from your view you may need to put parentheses around your pipe like this:
<input value={{device.id ? (device.id | decimalToHex) : ''}}>
if you leave them off like this:
<input value={{device.id ? device.id | decimalToHex : ''}}>
Then you get this error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With