Quiero desplazarme hacia abajo al hacer clic, intenté usar scrollIntoView , se desplaza hasta la mitad de la página, no hasta la sección de div
archivo .ts
@ViewChild("serviceBox", {static: false}) private serviceBox: ElementRef; showService() { setTimeout(() => { this.serviceBox.nativeElement.scrollIntoView({behavior: 'smooth'}) }); }.HTML
<div class="row" [style.display]="commonService.showService ? 'block' : 'none'"> <div class="col-md-12"> <div class="ticket__box" #serviceBox> <app-service-details [contractId]="contractId" [contactId]="contactId" [memberID]="memberID" [serviceId]="commonService.serviceId"></app-service-details> </div> </div> </div>Puedes hacerlo así:
showService() { let position = document.getElementById("serviceBox").getBoundingClientRect().top + window.scrollY - 25; window.scrollTo({ top: position, behavior: 'smooth' }); }