Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Expected the operants to be of similar type or any when using ngIf with type Number

I have a model as

class AnnouncementDocument {
  Id: String;
  IsDeleted: Boolean;
  Name: String;
  TemporaryName: String;
  Description: String;
  AnnouncementDocumentTypeId: Number;
}

in my template i am using

*ngIf="announcementDocumentTypeId==1

and i get the error

[Angular] Expected the operants to be of similar type or any

which is right, because 1 in template is treated as string not number

how can i solve the issue ?

like image 405
Arash Avatar asked Oct 09 '17 13:10

Arash


1 Answers

To check the type too , you will have to use === , Just check

*ngIf="announcementDocumentTypeId===1
like image 86
Sajeetharan Avatar answered Oct 15 '22 19:10

Sajeetharan