javascript - 减去 [ngStyle] 角度 6 内的变量
问题描述
我正在width
通过减去变量regOtValue
和endTimeOverTimeOut
在我的 [ngStyle] 指令中使我的进度条的样式属性动态化。但它总是抛出空白或插值错误(通过{{ }}
在 [ngStyle] 内添加)
这就是我正在做的事情:
[ngStyle]="{'width': (getAttendance.regOtValue - getAttendance.attendance[getAttendance.findIndex].endTimeOverTimeOut) + '%', 'background-color': '#63B3EA'}"
请帮助我跟踪我的发展。
先感谢您!
解决方案
尝试从如下方法返回一个值:
内部.ts
文件:
getWidth() {
return (this.getAttendance.regOtValue - this.getAttendance.attendance[getAttendance.findIndex].endTimeOverTimeOut).toString() + '%';
}
在您的模板中:
[ngStyle]="{'width':getWidth(), 'background-color': '#63B3EA'}"
推荐阅读
- javascript - DataTable rows.every 函数问题
- transformation - 如何改进这个平方根转换代码?
- python - curve_fit 使调用 func 引发 IndexError
- oracle - Oracle:如何计算运行总计
- c# - 获取 .net core 中的开放通用类型列表
- java - 如何在slider zoom sdk android中隐藏参与者?
- javascript - console.log 正在工作,但我无法收到任何警报。三个警报都没有出现。需要做什么?
- json - 从 json discord.py 中随机选择
- python - 如何使用 SIFT/SURF/KAZE 等特征提取器针对一张目标图像创建相似度分数
- python - 自动化要求输入密码的 bash 脚本