更新时间:2023-12-03 16:22:46
我遇到了同样的问题并找到了解决方法,虽然它不是***的。
I got the same issue and found a workaround, although it's not optimal.
您可以从文档中看到 [virtualScroll]
期待数组。当您的 this.ads
返回可观察时。这就是为什么你得到无法读取null
的属性'length'。
You see from the documentation [virtualScroll]
expect an Array. While your this.ads
return an Observable. That's why you got Cannot read property 'length' of null
.
解决方法:首先订阅它然后显示在查看(没有异步管道),完成后也要记住unsubsribe。
Workaround: Subscribe to it first then display on view (without async pipe), also keep in mind to unsubsribe when done.
ads: any[] = [];
constructor(public adProvider: AdProvider) {
this.adProvider.getActiveAds().valueChanges().subscribe(results => this.ads = results);
}