我想在6号角上实现分页。如果偏移为0,如何阻止“ Previos”(或更确切地说,使其完全消失),否则必须再次激活。
html按钮:
<div *ngIf="!loading; else loader">
<div *ngIf="notes.length !== 0; else empty">
......
<button mat-button (click)="Previos()" *ngIf="!loading; else loader">Previos</button>
<button mat-button (click)="Next()" [ngStyle]="{display: noMore ? 'none' : 'inline-block'}" *ngIf="!loading; else loader">Next</button>
</div>
</div>
ts:
const STEP = 10
const LIMIT = 10
nSub: Subscription
notes: Note[]
loading = false
noMore = false
limit = LIMIT
offset = 0
private loadNotes() {
const params = {
limit: this.limit,
offset: this.offset
}
this.loading = true;
this.nSub = this.noteService.fetch(params, this.notes_id).subscribe(
notes => {
this.notes = notes
this.noMore = notes .length < STEP
this.loading = false
}
);
}
Next() {
this.offset += STEP
this.loading = true
this.loadNotes()
}
Previos() {
this.offset -= STEP
this.loading = true
this.loadNotes()
}
答案 0 :(得分:1)
您不能添加到ngIf,偏移量== 0?
Previos