I는 TableComponent
의 일부인 표 가지고 swapProjectsGroups()
방법 때다른 성분 소자의 상부에 하나의 성분 트리거 두루마리
<table class="th-tracker-table th-environmental-table" #trackerTable>
I는 MyComponent
에서 액세스하고 구성 요소의 상단으로 스크롤 할를
export class MyComponent {
@ViewChild("#trackerTable") trackerTable: ElementRef;
public swapProjectsGroups() {
this.trackerTable.nativeElement.scrollTo(0,0); //Error: Cannot read property 'scrollTo' of undefined
}
}
을 유발하지만 내가 nativeElement를 초기화하는 뭔가를 놓친 거지, Cannot read property 'scrollTo' of undefined
을 얻을?
이것을 달성하기위한 각도 2 방법은 무엇입니까?
내가 nativeElement 추가하는 데 필요한 것 : this.trackerTable.nativeElement.scrollTo (0, 0); b 하지만 지금 얻을 수 없습니다 정의되지 않은 속성 'nativeElement'읽을 수 – commonSenseCode
this.trackerTable.nativeElement.scrollTop = 0; 을 호출하고 호출을 트리거하는 라이프 사이클 이벤트를 기억하십시오. – kit