Virtual Scroll - enabled on condition

懵懂的女人 提交于 2021-01-05 08:41:29

问题


I'm working on big data tables and I need to have oportunity to set dynamic if I want to use virtual scroll or standard solution. On my prototype I used *ngIf and duplicated views for standard body and cdk virtual scroll vierport. Is there any possibilty to just disable virtual scroll, without building additional components for alternate views? Thanks in advance!


回答1:


I believe you are asking for adding the virtual scroll directive based on a condition. In that case, it cannot be done at the moment. There is no way to add a directive to an element based on a condition. It has to be statically bound to the HTML to define it's behavior. There are 2 workarounds:

  1. Have two different views. One when the condition is true and one when the condition is false. I understand this is what you're doing right now.

  2. If you are the author of the directive, pass an argument to the directive to instruct it to not do anything. Unfortunately since you are using a library, this solution wouldn't be possible.

Please see here: https://github.com/angular/angular/issues/5332



来源:https://stackoverflow.com/questions/60383638/virtual-scroll-enabled-on-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!