【发布时间】:2016-12-09 20:05:11
【问题描述】:
问题
Angular 2.2 之后的版本。 *,我注意到我的应用程序的某些组件中存在一个问题,即更新数据后,视图中的数据是错误的(它以正确的大小显示列表,但仅包含第一项的数据)。
演示
我创建了this Plunker with a simple example 的问题。
这种使用方式会导致问题:
<list-component [data]="list">
<template pTemplate let-item>
<b *ngIf="item % 2 == 0">{{item}}</b>
<del *ngIf="item % 2 != 0">{{item}}</del>
</template>
</list-component>
问题发生说明:
- 在 Plunker 中打开示例;
- 观察第二块(模板为
*ngIf:) - 点击“刷新”按钮;
- 再次查看第二个块(带有
*ngIf的模板:);
问题
什么可能导致此问题以及如何解决?
【问题讨论】: