使用身体作为容器的md-virtual-repeater [英] md-virtual-repeater using body as container

查看:66
本文介绍了使用身体作为容器的md-virtual-repeater的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用Angular Material的虚拟重复来实现类似Facebook的功能,其中帖子可以无限滚动.

I am planning to use Angular Material's virtual repeat to achieve a Facebook like functionality where posts infinitely scroll.

是否可以在HTML文档的body标签上使用虚拟重复容器?

Is it possible to have the virtual repeat container on the body tag of the HTML document?

我不知道如何运作.我的SPA应用程序中有不同的路线,我需要根据页面是否使用无限滚动来动态添加/删除主体上的虚拟重复容器.

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...

实现md-virtual-repeat以使HTML正文成为滚动容器的可行策略是什么?

What's a viable strategy for implementing md-virtual-repeat for having the HTML body to be the scroll container?

我还没有遇到任何将容器放置在body元素上的示例.

I have not come across any examples which put the container on the body element.

任何帮助将不胜感激.

推荐答案

经过一番摆弄,我找到了答案.

After some fiddling around, I've found the answer.

如果您使用的是Angular Material,答案实际上非常简单,坚持坚持使用Angular Material.

The answer is actually very simple, if you're using Angular Material, stick to Angular Material.

我使用了所有布局(即容器,导航,sidenav),但我发现Angular Material不会使用浏览器的主体进行滚动.所有内容都包含在其container元素中.只需在上面放一个md-virtual-repeat-viewport,您就可以开始了!

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!

这篇关于使用身体作为容器的md-virtual-repeater的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆