angular - div[id]=function 不能调用相应的打字稿函数?
问题描述
我需要将 Employee 值列表从 html 传递给 typescript 函数。我需要根据 typescript 中的五个条件更改员工交易记录的图像,为此我正在使用 Div [id]=function.The 函数根据条件返回相应的 css 类名称。由于我有 5 个条件,我无法使用 ngif,另外我需要传递员工列表。上面的 html 代码也有一个员工列表列表,我已经在上面循环。问题是在 html 中声明的这个函数没有调用相应的 ts 函数。所以请告诉我该方法是否正确或需要更改。
**HTML**
<div [id]="getEmployeeId(Employee)">
<div id="h31">
<em class="" style="font-size: 0.7rem;font-weight: bold;"></em>
</div>
</div>
**TS**
getEmployeeId(Employee) {
for (var EmployeeList of Employee){
if ((EmployeeList.EmployeeStatus== 'Active') {
this.inputDisabled = false;
return 'circle3'; //noicon
}
else if ((EmployeeList.IsEmpty== true) {
this.inputDisabled = true;
return 'circle4'; //orange
}
else if (EmployeeList.Employeestatus == 'Error') {
this.inputDisabled = true;
return 'circle6'; //red
}
else if (EmployeeList.transactionStatus == 'Completed') {
this.inputDisabled = true;
return'circle2'; //green
}
else if (EmployeeList.transactionStatus == 'Screened') {
this.inputDisabled = true;
return 'circle5'; //blue
}
}
}
**CSS**
#circle2{
width: 24px;
height: 24px;
margin: 5px 25px;
border-radius: 30px;
margin-right: 15px;
background: #a9d18e;
display: flex;
解决方案
推荐阅读
- binary - 定点格式的负数
- c# - 使用EF核心和c#数据绑定进行数据绑定时刷新数据
- opencv - 在 OpenCV DNN C++ 中加载冻结图
- python - 如何在manim的圆圈上绘制等距的点?
- javascript - Facebook 营销 API 仅返回 25 个结果/广告
- c++ - 如果我传递一个包含容器的容器,我该如何构建我的模板
- google-cloud-platform - 如何在 GKE 中使用更新的 CUDA 版本?
- r - 强制 ggraph 中 geom_node_text 中节点的标签重复
- javascript - 在for循环中let和var的不同输出?任何人都可以解释的原因是什么?提前致谢
- svn - 如何将单独的存储库作为项目移动到其他存储库