19

Im using this block in my html template :

  <div *ngIf="visibleblock && !selected?.item?.externalInfo?.length > 0">

But im getting this error when i do:

ng build --prod --aot

Any suggestion how can i fix this ?

None
  • 8,817
  • 26
  • 96
  • 171

1 Answers1

41

Put the second expression inside parenthesis:

<div *ngIf="visibleblock && !(selected?.item?.externalInfo?.length > 0)">
FAISAL
  • 33,618
  • 10
  • 97
  • 105
  • Its working.. Can you explain what is the difference between these ? – Krunal Dec 21 '18 at 07:18
  • 4
    @Krunal For example: `!a.length` returns a boolean value because it will check if the length of `a` exists. So writing `(!a.length > 0)` will compare a boolean value to 0. `!(a.length > 0)` will check if the comparison inside the paranthesis (number versus number) is a boolean value true or false. That's the difference and that's why OP got an error message. – mahval Jan 16 '19 at 13:10