我是Angular 2的新手。嘗試使用滾動事件進行其他調用。我有200條記錄,最初我會做這樣的休息電話Angular 2:滾動事件不會觸發
localhost:8080/myapp/records=items&offset=0&limit=50
它將首先獲取50條記錄。但是,當我向下滾動它再拍API調用獲取另外50分的記錄,像
localhost:8080/myapp/records=items&offset=50&limit=50
我嘗試這樣做,但不觸發事件。
HTML
<div>
<table class="doc-table" (scrolled)="onScroll($event.value)">
<thead>
<th class="avatar-th"></th>
<th>Id</th>
<th>Name</th>
<th>Price</th>
</thead>
<tbody>
<tr *ngFor="let item of items" (click)="routeTo(item.id)">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td>{{item.price}}</td>
</tr>
</tbody>
</table>
</div>
腳本上抵消我必須做出API調用
@Component({
selector: 'item-cmp',
templateUrl: 'items.component.html'
})
export class PatientsComponent(){
onScroll(event:any){
alert("Scolled...");
}
}
基地。幫助我,如何做到這一點?
感謝您的回覆。但是,仍然沒有工作。 – NNR
很難從這裏知道,也許表格不是發出滾動事件的元素。 –
什麼是「不工作」的意思。 '$ event.value'應該做什麼。據我所知'event'沒有'value'屬性。 –