其他分享
首页 > 其他分享> > Operator '>' cannot be applied to types 'boolean' and 'number'?

Operator '>' cannot be applied to types 'boolean' and 'number'?

作者:互联网

https://stackoverflow.com/questions/45974764/operator-cannot-be-applied-to-types-boolean-and-number

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 ?

      

Put the second expression inside parenthesis:

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

原因是 , !变成了boolean类型, 然后他 不能用>0比较。 需要吧 length>0 括号括住然后再加!。

小细节啊!
   

标签:applied,boolean,括住,number,cannot,types
来源: https://www.cnblogs.com/java2sap/p/13047934.html