#ngif incorrectly evaluates a simple boolean

13 messages · Page 1 of 1 (latest)

frozen trout
#

Can someone explains me what is wrong here ? There is obviously something wrong here but cant find it...

<td class="text-center"><i *ngIf="lps.fast" class="fas fa-check"></i>{{lps.fast}}</td>
Always evaluates to true even when lps.fast (which is a boolean) is false

Watch captures for detail

rare sparrow
#

Hello @frozen trout , check the value: is it false or "false"?

frozen trout
#

it is a boolean, so false and not "false"

rare sparrow
#

is it coming from an api call?

frozen trout
#

yes

rare sparrow
#

Typescript can't assert data coming from an api call, I encourage you to check with Network tab if fast is really a boolean.

#

Because that would be the only reason for your situation

frozen trout
#

yes that was it, silly me

#

the attribute was a string ad not a boolean :/

#

thanks for your fresh eye, I was becoming mad 😄

steep onyx
rare sparrow
steep onyx
#

I think you get a diagnostic about that 🙂