I am working with scroll and try to initiate it at specific element by a given id.
my html looks like:
<div class="list-wrapper" style="max-height:350px;overflow-y:scroll" >
<div *ngFor="let el of elements">
<div class="text-center" id="element_{{el.id}}"
{{el.lebel}}
</div>
</div>
</div>
in my component
Future ngOnInit() async{
await _apiService.getElements().then((resp){
list = resp;
});
scrollToLastElement();
}
my scrollToLastElement method
void scrollToLastElement(){
var wrapper = querySelector('.list-wrapper');
Timer.run(() => wrapper?.scrollTop = wrapper?.scrollHeight);
}
but scroll always point at the first one. any suggestions ?