cdkVirtualFor does not work in ng-content
What is the expected behavior?
when *cdkVirtualFor in ng-content, and cdk-virtual-scroll-viewport in parent component, everything works fine.
What is the current behavior?
when *cdkVirtualFor in ng-content, and cdk-virtual-scroll-viewport in parent component, error happend
ERROR
Error: StaticInjectorError(AppModule)[CdkScrollable -> CdkVirtualScrollViewport]:
StaticInjectorError(Platform: core)[CdkScrollable -> CdkVirtualScrollViewport]:
NullInjectorError: No provider for CdkVirtualScrollViewport!
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
https://stackblitz.com/edit/angular-oqcthb?file=src/app/app.component.html
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Is there anything else we should know?
Any news on this ?
Yea any news?
Any News ??
Same issue
Any news?
Any news ?
any news?
Any updates? Same issue..
This is a limitation of Angular's content projection. https://github.com/angular/angular/issues/37319 has been filed to hopefully improve some of the short-comings
Here is a working example of the above provided stackblitz. It's not 100% but should provide a somewhat feasable strategy.
- The
VirtualForDirectiveprovides the template used for stamping out items. - The
VirtualForDirectiveprovides a reference (viewContainerRef), later used to replace content. - The
VirtualScrollViewportComponentprovides a wrapper containing the real CDK scrolling. - The
HelloComponentusesAfterContentInitto get a hold ofVirtualForDirectiveand attaches it to the viewport.
https://stackblitz.com/edit/angular-yq1gya
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.