My angular (6) code is set up so I have a section (We'll call this pageOne) on the bottom of the page that is tied to an ngIf
. I want there to be a button on the top of the page, that when pressed displays pageOne
by making it true, and then automatically scrolls to the bottom of the page.
I am able to get it to be true and display no problem, the only issue I'm having is getting it to scroll to the new section. Pressing the button once displays the content, and I have to press it again to get it to scroll down. I'm hoping to achieve this all on 1 click. I don't believe it's a time issue, I think it doesn't see the content on the page till the second click. Not sure though.
<button (click)='onDisplayContent()'>Start</button>
<div *ngIf="pageOne">
...
</div>
onDisplayContent() {
this.pageOne = true;
this.pageThree = true;
this.scrollDown();
}
scrollDown() {
window.scrollTo(0, document.body.scrollHeight);
}