“Auto przewiń do dna Div Angular” Kod odpowiedzi

scoll a Div do dna w kąt

import {..., AfterViewChecked, ElementRef, ViewChild, OnInit} from 'angular2/core'
@Component({
    ...
})
export class ChannelComponent implements OnInit, AfterViewChecked {
    @ViewChild('scrollMe') private myScrollContainer: ElementRef;

    ngOnInit() { 
        this.scrollToBottom();
    }

    ngAfterViewChecked() {        
        this.scrollToBottom();        
    } 

    scrollToBottom(): void {
        try {
            this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
        } catch(err) { }                 
    }
}
Dark Dogfish

Auto przewiń do dna Div Angular

<div style="overflow: scroll; height: xyz;" #scrollMe [scrollTop]="scrollMe.scrollHeight">
    <div class="..." 
        *ngFor="..."
        ...>  
    </div>
</div>
Precious Panther

Auto przewiń do dna Div Angular

Angular scroll from bottom to top
Selfish Spider

Odpowiedzi podobne do “Auto przewiń do dna Div Angular”

Pytania podobne do “Auto przewiń do dna Div Angular”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu