最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - angular loading animation while content is loading - Stack Overflow

programmeradmin4浏览0评论

I have an angular page that loads some content on a local drive. So its running without a webserver. Sometimes its loading quiet long (10secs).

I tried to implement a jquery loading animation, but even the jquery loading animation starts after the normal content is loaded from the JS.

This is how the page looks while its loading my angular content:

How Can I implement a loading spinner or text, instead of showing the raw {{example.example}} values?

Thanks.

I have an angular page that loads some content on a local drive. So its running without a webserver. Sometimes its loading quiet long (10secs).

I tried to implement a jquery loading animation, but even the jquery loading animation starts after the normal content is loaded from the JS.

This is how the page looks while its loading my angular content:

How Can I implement a loading spinner or text, instead of showing the raw {{example.example}} values?

Thanks.

Share Improve this question edited Oct 3, 2018 at 15:49 Kalamarico 5,65622 gold badges56 silver badges73 bronze badges asked Oct 3, 2018 at 14:10 MisterGomez93MisterGomez93 931 gold badge1 silver badge3 bronze badges 1
  • Hello ! Welcome to StackOverflow ! What did you try ? – Zooly Commented Oct 3, 2018 at 14:15
Add a comment  | 

1 Answer 1

Reset to default 21

Before angular load you can show your loader on index.html page without any javascript code. Just paste following code in your index.html

<app-root>
<div class="loader"></div>
</app-root>

Paste following code in header tag of index.html

<style>
.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid #3498db;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 2s linear infinite; /* Safari */
  animation: spin 2s linear infinite;
}

/* Safari */
@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>

When angular will loaded successfully then code in app-root component will be replaced by original content.

发布评论

评论列表(0)

  1. 暂无评论