javascript - Angular 2+递归嵌套问题
问题描述
我遇到了递归嵌套组件的一个奇怪问题。嵌套基于一个数组,其中每个下一个项目将在嵌套中增加一层(块对象中的数组称为实体):
<app-chunk [chunk]="chunk" [increment]="(increment + 1)"></app-chunk>
-
@Input() chunk;
ngOnInit() {
// Check if it's the final nesting
if (!this.chunk.entities || this.chunk.entities.length <= this.increment) {
this.isThrough = true;
} else {
this.isThrough = false;
}
}
到目前为止,嵌套工作正常,但是,当我更改数组时,更改不会反映在整个嵌套组件中。
例如,从数组中删除,应该会导致嵌套组件的一级消失,这不会发生。基本上,我需要完全重新渲染递归组件树,对吧?
但是,这无论如何都可以做到吗?(已经尝试过 NgZone.run, ApplicationRef.tick) => 还没有成功
解决方案
推荐阅读
- swift - 为什么 UISegmentedControl 将我图像的蓝色部分变为黑色?
- c++ - 如何使用内存以及 const char* const arr[][] 的大小是多少?C++
- javascript - 如何使用 JQuery 从外部文件中获取对象?
- java - -XX:HeapDumpPath 文件输出到远程位置
- python - 有没有更有效的方法来根据列的内容从 PyArrow 表中选择行?
- spring - 如何分别处理来自 HTTP 和 HTTPS 的请求 Spring Boot 2 在两个单独的端口上运行 Tomcat?
- google-bigquery - BigQuery:连接两个数组并在 MERGE 语句中保留不同的值
- reactjs - 当表单验证出错时,如何防止按钮提交表单起作用?
- java - 如果用户移动或重命名文件,您的应用能否跟踪用户的文件?
- azure-active-directory - 使用 Azure AD 帐户登录 Windows 时,圆点永无止境