Is it possible to load a component in place of loading... between <app-root> within the index.html of an Angular project?
When the Angular app is loading, if the connection is slow etc while the page loads, whatever is displayed between the <app-root></app-root> tags within the index.html file will be displayed on the screen.
I am wanting to place a spinner at the point such that it will look like something is happening in the background rather than have an blank white screen.
Here is the code for the spinner:
.lds-ring {
display: inline-block;
position: relative;
width: 64px;
height: 64px;
}
.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 51px;
height: 51px;
margin: 6px;
border: 6px solid var(--pa-red);
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: var(--pa-red) transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
body {
background: grey;
}
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
</div>
If I use this in the actual index.html file it does indeed work. However, If I have this as a component amongst my others and load it with the selector, ie:
<app-root>
<app-spinner></app-spinner>
</app-root>
Nothing is displayed and the white screen is seen while waiting.
Is there a solution to this?