My app is being developed in Angular 5. I want to load the background image first
<div id="mainDiv" class="sign-in" [ngStyle]="{'background-image': 'url(' + background_source + ')'}">
and only then load the rest of the page.
Already tried:
- window.onload
- window.document.onload
- document.getElementById("mainDiv").addEventListener("load", function...)
All this methods are triggered before the image fully renders on the page.
I simulate a slow network using Chrome's developer option "Slow 3G Network"
While the image is rendering all this events have already been triggered. Can't find a simple way to make it work. Any suggestion would be appreciated. Many thanks in advance