问题
I am planning to use Angular Material's virtual repeat to achieve a Facebook like functionality where posts infinitely scroll.
Is it possible to have the virtual repeat container on the body tag of the HTML document?
I don't see how that will work. I have different routes in my SPA app, I will need to add/remove the virtual repeat container on the body dynamically depending on if the page uses infinite scroll or not...
What's a viable strategy for implementing md-virtual-repeat for having the HTML body to be the scroll container?
I have not come across any examples which put the container on the body element.
Any help would be appreciated.
回答1:
After some fiddling around, I've found the answer.
The answer is actually very simple, if you're using Angular Material, stick to Angular Material.
I've used all the layouts (i.e. container, nav, sidenav), I've found that Angular Material does not use the browser's body to scroll anyway. All content is contained in their container
element. Simply put a md-virtual-repeat-viewport
on there and you are good to go!
来源:https://stackoverflow.com/questions/41175828/md-virtual-repeater-using-body-as-container