【发布时间】:2016-09-28 09:51:12
【问题描述】:
我是 Angular 2 的新手。尝试使用滚动事件进行休息调用。我有 200 条记录,最初我会像这样打一个休息电话
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>
脚本
@Component({
selector: 'item-cmp',
templateUrl: 'items.component.html'
})
export class PatientsComponent(){
onScroll(event:any){
alert("Scolled...");
}
}
基于偏移量,我必须进行 API 调用。帮帮我,怎么办?
【问题讨论】:
标签: javascript angular