Angular 在ionic 2中使用virtualScroll显示通过http请求获取的数据时出错

Angular 在ionic 2中使用virtualScroll显示通过http请求获取的数据时出错,angular,ionic2,Angular,Ionic2,我正在尝试在离子2中使用虚拟滚动。虚拟滚动应该显示http请求获取的元素。使用*ngFor everything时效果很好,但使用virtual scroll时出现错误: browser_adapter.js:77 TypeError: Cannot read property 'indexOf' of undefined HTML: 当单击另一个选项卡并单击返回此视图时,我会看到从一开始就应该显示的所有信息 谢谢你的帮助;) 我的代码中也有同样的问题。我通过在模板中添加属性*ngIf来解决这

我正在尝试在离子2中使用虚拟滚动。虚拟滚动应该显示http请求获取的元素。使用*ngFor everything时效果很好,但使用virtual scroll时出现错误:

browser_adapter.js:77 TypeError: Cannot read property 'indexOf' of undefined
HTML:

当单击另一个选项卡并单击返回此视图时,我会看到从一开始就应该显示的所有信息


谢谢你的帮助;)

我的代码中也有同样的问题。我通过在模板中添加属性
*ngIf
来解决这个问题,检查对象是否存在。F.eks:

<ion-list [virtualScroll]="posts" *ngIf="!cantDoRequest">
            <ion-div *virtualItem="#post">
                <ion-item-sliding *ngIf="post && post.bereich && post.bereich.indexOf('CallCenter')>-1 && callc == 'true'">
                    <button ion-item text-wrap (click)="itemTapped($event, post)" *ngIf="post && post.bundesland && post.bundesland.indexOf('Baden-Württemberg')>-1 && baden == 'true'">
...

...

我在
*ngIf
-语句中添加了一些额外的检查

我的代码中也有同样的问题。我通过在模板中添加属性
*ngIf
来解决这个问题,检查对象是否存在。F.eks:

<ion-list [virtualScroll]="posts" *ngIf="!cantDoRequest">
            <ion-div *virtualItem="#post">
                <ion-item-sliding *ngIf="post && post.bereich && post.bereich.indexOf('CallCenter')>-1 && callc == 'true'">
                    <button ion-item text-wrap (click)="itemTapped($event, post)" *ngIf="post && post.bundesland && post.bundesland.indexOf('Baden-Württemberg')>-1 && baden == 'true'">
...

...

我在
*ngIf
-语句中添加了一些额外的检查

谢谢,但不知何故,错误消息消失了,我根本没有更改代码。但我还是要用你的方法谢谢,但不知怎么的,错误信息消失了,我根本没有更改代码。但我还是要用你的方法
<ion-list [virtualScroll]="posts" *ngIf="!cantDoRequest">
            <ion-div *virtualItem="#post">
                <ion-item-sliding *ngIf="post && post.bereich && post.bereich.indexOf('CallCenter')>-1 && callc == 'true'">
                    <button ion-item text-wrap (click)="itemTapped($event, post)" *ngIf="post && post.bundesland && post.bundesland.indexOf('Baden-Württemberg')>-1 && baden == 'true'">
...