angular - html 中的 onChange 转换为 Angular 是什么样的?
问题描述
我有一个“跨度”,当“h2”值等于空时会显示,当“h2”值不为空时会消失。我尝试实现 OnChanges,以便它们相互跟踪值。
我的ts
remindNotify(){
var x = document.getElementById("notifyTitle");
var y = document.getElementById("badge");
if(x == null){
y.style.display= "block";
}else{
y.style.display= "none";
}
}
ngOnChanges(changes: SimpleChanges): void{
this.remindNotify();
}
我的html
<span id="badge">#</span>
<h2 id="notifyTitle" >{{ (message | async)?.notification.title }}</h2>
解决方案
推荐阅读
- unit-testing - 对 setter 和 getter 进行单元测试 - 最佳实践
- python - '^' 是什么意思?
- javascript - 带有 url 参数的 Next.js 站点地图
- c++ - 类的容器 get() 成员函数使用 vs 复制
- android - 记住我的 SharedPreferences 在 android 中运行缓慢。如何让它更快地工作?
- vaadin - Vaadin 21:将 Scroller 嵌套到 VerticalLayout 问题中
- javascript - 如何在商店中为 React Native App 编辑我的 Firebase 规则,以便发送数据而无需经过身份验证?
- flutter - 滚动后显示应用栏 - Flutter
- c# - 使用 OfficeOpenXml 格式将图像从 C# 代码插入 docx 文件
- flutter - 没有 Future.delayed 的代码不会在 catch 上执行