angular - 使用 angular7 一个一个地显示组件的子级
问题描述
我正在创建某种假聊天,让人们通过一些稍微复杂的步骤进行计算。这是一个仅包含重要部分的迷你示例:https ://stackblitz.com/edit/angular-htxjt9
<chat>
<them>Hi</them>
<you>Hello!</you>
<them>Do you want to continue?</them>
<you><button (click)="this.continue = true">Continue</button></you>
</chat>
<chat *ngIf="this.continue">
<them>You started the next step</them>
<them>Thanks</them>
<you>Awesome</you>
</chat>
一旦一个<chat>
组件初始化,它的所有直接子节点都需要一个一个地变得可见,延迟约 2 秒。
最好的方法是什么?
解决方案
如评论中所述,您应该尝试使用 rxjs 延迟运算符。在示例中,我使用了 BehaviorSubject。由于这是一个示例,因此我省略了取消订阅。请不要忘记它。
在此处查看我的 stackblitz 示例:https ://stackblitz.com/edit/angular-dvtban
推荐阅读
- excel - 从已关闭的 Excel 工作表中复制整个数据并将其作为值和格式粘贴到活动工作簿
- azure - Databricks 集群已终止。原因:云提供商启动失败
- android - 去除安卓手机底部的空白
- javascript - 遍历 VUE v-for 循环时出现对象错误
- scikit-learn - sklearn 的 LinearRegression 是否使用 SVD?
- javascript - 如何将对象转换为数组并添加键
- cplex - 获取探查器错误 i CPLEX OPL - 发生溢出
- python - Python Selenium - 使用 Internet Explorer 发送密钥
- gitlab - 如何设置 Markdown 表格列的最小宽度?
- python - 使用 Python 优化以分数为约束的线性规划问题