41
loading...
This website collects cookies to deliver better user experience
In a long page, wait for a specific HTML Element to appear, and only after its generation scroll to it.
*ngIf
statement. As you can see bellow, this is achieved by setting the variable showTable
to false at startup. This DOM concept is important to understand, because if you have decided to use hidden
attibute instead of *ngIf
strategy, the table would be already on your page and DOM, the only thing is that it would be hidden.waitAndGoDown()
is called. This will be described in details next.<div style="text-align: center">
<button (click)="waitAndGoDown()">Wait Random time and go Down</button>
<p>
<div *ngIf="showSpinner" class="loader">Loading...
</div>
</div>
simulateBackend()
function uses a random setTimeout
limited to 5 seconds to randomize the return of the fake Backend. This means that after a while the Spinner is turned off and the grid is allowed to appear.simulateBackend
to return to invoke waitForElement
. That's why there's a need for some mecanism to monitor when the table appears (or when the DOM mutates) and eventually when to scrool to it.