SVG исчезает, поскольку HTML-код, определенный в app-root
в вашем index.html
, заменяется отображаемым компонентом app-root
после начальной загрузки приложения.
Для перехода вы можете переместить .app-loading
за пределыapp-root
и переведите его поверх вашего загруженного приложения, как вы хотите.В приведенной ниже демонстрации это просто полностью позиционированный полноэкранный режим.
Вы можете дождаться завершения обещания platformBrowserDynamic().bootstrapModule(...)
для запуска перехода.
index.html
<div class="app-loading">
...
</div>
<app-root></app-root>
main.ts (или где ваше приложение загружено)
// loading element container to transition
const loadingElement = document.querySelector(".app-loading");
platformBrowserDynamic()
.bootstrapModule(AppModule)
// trigger the transition
.then(() => loadingElement.classList.add("loaded"))
// remove the loading element after the transition is complete to prevent swallowed clicks
.then(() => setTimeout(() => loadingElement.remove(), 1000));
