【发布时间】:2020-08-12 15:57:01
【问题描述】:
我在使用 *ngIf 根据某些标志显示不同类型的图表时遇到问题。 它在 chrome 中工作,但在 IE11 中工作。 *ngIf 内容在 flag 为 true 时被添加到 DOM,如果 flag 为 false 则不会被删除。
因此,每次我切换标志时都会创建新图表。
请帮助我。如果我做错了什么。
上下文: 我们有两种类型的表单复选框/单选框。一旦用户点击提交按钮。图表将相应呈现 复选框 - 条形图 Radiobox - 饼图
使用 *ngIf 切换内容。它在 chrome 中工作。
在 IE11 中, *当 ngIf 标志设置为 false 时。元素不会被删除和替换,而是创建一组新的图表和表单。
<ht-check-form
*ngIf="!chartDisplay"
[surveyDetails]="survey"
(onFormSubmit)="submitSuvery($event)"
></ht-check-form>
<ht-chart
*ngIf="chartDisplay"
[surveyDetails]="survey"
[chartResult] = "chartData"
></ht-chart>
示例代码在 plunker 中:https://plnkr.co/edit/bANp2nJzyVMTFpK9F8NE?p=preview
【问题讨论】:
-
感谢您的帮助。
-
我遇到了同样的问题。
标签: angular cross-browser internet-explorer-11 angular-ng-if ngx-charts