rhdtp
rhdtp

Reputation: 75

Why the button inside table in modal not working?

Why is the button inside the table row not working?

I am only expecting it to print a message in the console by calling a function in the modal-basic.ts file.

modal-basic.html:

<td><button (click)="test()">Test</button></td>

modal-basic.ts:

test() {
  console.log("Test...");
}

You can find a minimal reproducible example in the following StackBlitz: https://stackblitz.com/edit/angular-bpp4uh

Upvotes: 5

Views: 709

Answers (1)

rajhim
rajhim

Reputation: 269

I have done some changes.

removed this code in ts.

 get countries(): Country[] {
    return COUNTRIES
      .map((country, i) => ({id: i + 1, ...country}))
      .slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
  }

declare

countries = [];

add in ngOnit or constructor()

{this.countries = COUNTRIES;}

In html

 *ngFor="let country of countries | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize"

<ngb-pagination
  [(page)]="page"
  [pageSize]="pageSize"
  [collectionSize]="countries.length"></ngb-pagination>

here is the link:

https://stackblitz.com/edit/angular-8dxiv4

Upvotes: 2

Related Questions