问题
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:
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.
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