[英]How to create global preloader to all components. Angular 2
I need to create a component which will add preloader (image with semi-transparent background) to all components, which loading or fetching data from service. 我需要创建一个组件,该组件将向所有组件添加预加载器(具有半透明背景的图像),从而从服务加载或获取数据。 I have some routable blocks on page.
我在页面上有一些可路由的块。 And I need to show preloader over the block, which working in the moment.
我需要向该块显示预加载器,此块当前可以正常工作。 Which of events should I handle?
我应该处理哪个事件? And how to make it globaly?
以及如何使其具有全球性? Thank you.
谢谢。
I think you could start by creating a custom directive for eg <my-loader></my-loader>
and in that component you could add your Preloader, images etc then by simply adding it to any of your component view by including it in directive[]
. 我认为您可以先为
<my-loader></my-loader>
创建一个自定义指令,然后在该组件中添加Preloader,图像等,然后通过将其包含在任何组件视图中将其添加到任何组件视图中directive[]
。 Hope this answers as the question itself is quite abstract , some snippet would definitely help. 希望这个答案能够回答,因为问题本身是非常抽象的,一定会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.