angular - Angular:在元素位于 DOM 之后运行 ChangeDetection?
问题描述
我在模态对话框中有一个组件。我注意到组件的 @Inputs 在元素实际位于 DOM 之前触发!这会导致不良的布局行为。在运行更改检测之前,如何确保元素在 DOM 中?
笔记:
我目前正在使用这个黑客。我认为有一种更优雅的方式:
class MyDialog implements AfterViewInit {
@ViewChild(ChartElement)
ChartElement chart;
@override
void ngAfterViewInit() async {
while(document.getElementById('#myElement') == null) {
await Future.delayed(Duration(milliseconds: 100));
}
chart.draw();
}
}
解决方案
推荐阅读
- mysql - 关于对象关系映射器(ORM)做关系数据库(join)工作的问题
- javascript - Mapbox 地理编码器仅在获取/创建路线中部分工作。为什么我的代码不能正常工作?
- node.js - 为什么在线上传时看不到我的 Web 应用主页?
- ubuntu - 让 x11vnc 在 Ubuntu 16.04 服务器中自动启动,而无需有人首先物理登录服务器
- java - System.getenv() 在 Eclipse (Mac) 上找不到环境变量
- excel - 使用 Excel VBA 时 Outlook 电子邮件性能变慢
- android - NFC 设备所有者配置和 Knox
- kubernetes - 使用具有多个端口和协议的相同 Istio Gateway
- c++ - WinAPI 无法创建按钮
- ios - 如何检测是否从设备设置了 HealthKit 数据?