【发布时间】:2021-03-20 23:34:00
【问题描述】:
如何将 ts 文件中的值转换为 HTML 文件中的 ngIf 条件? 我试过带或不带大括号,但它似乎不起作用。 sender_id 是数字类型。提前致谢!
.html 文件
*ngIf="item.Sender_ID != {{sender_id}}"
ts.文件
this.api.getStaffDetailsByUsername(this.username).subscribe(res=>{
console.log(res)
this.department = res[0].Departament;
this.sender_id = res[0].Staff_ID;
【问题讨论】:
-
.ts文件是角度组件吗?.html是组件模板? -
它应该只是
*ngIf="item.Sender_ID != sender_id"。在[...]和*...内部,一切都是表达式,而不是字符串。所以不需要插值
标签: javascript angular ionic-framework