Skip to content

Commit

Permalink
adding condition for previous and next page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorciney committed Nov 9, 2023
1 parent e69ec4c commit 774a052
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/app/ui/pagination.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { NgClass, NgForOf } from '@angular/common';
import { NgClass, NgForOf, NgIf } from '@angular/common';

@Component({
standalone: true,
selector: 'consent-flow-pagination',
template: `
<div class="w-full flex flex-row justify-between items-center gap-5 text-blue-600">
<a (click)="previousClick.emit()" class="p-1 cursor-pointer"><< Previous page</a>
<a *ngIf="currentPage !== 1" (click)="previousClick.emit()" class="mr-40 p-1 cursor-pointer"><< Previous page</a>
<div class="flex flex-row">
<ng-container *ngFor="let page of [].constructor(totalPages); let i = index">
<div
Expand All @@ -18,15 +18,15 @@ import { NgClass, NgForOf } from '@angular/common';
</div>
</ng-container>
</div>
<a (click)="nextClick.emit()" class="p-1 cursor-pointer">Next page >></a>
<a *ngIf="currentPage !== totalPages" (click)="nextClick.emit()" class="ml-40 p-1 cursor-pointer">Next page >></a>
</div>
`,
imports: [NgForOf, NgClass],
imports: [NgForOf, NgClass, NgIf],
})
export class PaginationComponent {
@Output() previousClick = new EventEmitter<void>();
@Output() nextClick = new EventEmitter<void>();
@Output() pageClick = new EventEmitter<number>();
@Input() currentPage: number;
@Input() currentPage: number = 0;
@Input() totalPages?: number;
}

0 comments on commit 774a052

Please sign in to comment.