我有一个模型
class AnnouncementDocument {
Id: String;
IsDeleted: Boolean;
Name: String;
TemporaryName: String;
Description: String;
AnnouncementDocumentTypeId: Number;
}
在我的模板中我正在使用
*ngIf="announcementDocumentTypeId==1
我收到错误
[Angular] Expected the operants to be of similar type or any
这是正确的,因为模板中的1被视为字符串而不是数字
我该如何解决这个问题?
答案 0 :(得分:3)
要检查类型,您必须使用 ===
,只需检查
*ngIf="announcementDocumentTypeId===1