ngIf条件中的TS文件值



如何将ts文件中的值获取到HTML文件中的ngIf条件中?我试过使用或不使用花括号,但似乎都不起作用。sender_id为数字类型。提前感谢!

.html文件

*ngIf="item.Sender_ID != {{sender_id}}"

ts.file

this.api.getStaffDetailsByUsername(this.username).subscribe(res=>{
console.log(res)
this.department = res[0].Departament;
this.sender_id = res[0].Staff_ID;

一旦ts文件中的字段被声明为public(如果不是#或使用private或protected,则为默认情况(,该字段在html代码中也可用。仅在表达式"之外;{…}";需要。在*ngIf指令中,它也可以直接作为项使用。

最新更新