简体   繁体   中英

User percentage loader in <app-root> Angular +2

My index.html is:

<body>
<app-root>
 Loading...
</app-root>
...
...

I have a pure css loader and it worked fine when I replace Loading... with my loader, Now I want to implement percentage loading from 0% to 100% but I can do nothing with functions or ts processing in my index.html. What is the best way to that?

Percentage loading depends upon your contents. If you know what and how much contents you need to load, you can divide 100 among each content. For example, if you have 5 different contents to load at startup, you can divide each 20% value. You have to then load the content asynchronously and increase a counter by 20 every time one of your content is loaded.

var perCounter = 0;

// load each content
perCounter = perCounter + 20;

How to show a percentage in HTML, is via various option you might choose one. One example is here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM