Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
562 views
in Technique[技术] by (71.8m points)

angular - pascalhonegger/ng-datatable onPageChange isn't triggered

I am attempting to load my data (pagination) dynamically using @pascalhonegger/ng-datatable, meaning I load the first page initially and then I'd like to call the API after the user tries to switch to the next page. However, the (onPageChange) event doesn't do anything. Am I missing something?

HTML template:

<table class="table table-striped table-hover table-responsive-lg" [mfData]="tableData" #mf="mfDataTable" [mfRowsOnPage]="10" (onPageChange)="doStuff($event)">
<thead>
    <tr>
    <th>
        {{ 'COLUMN1' }}
    </th>
    <th>
        {{ 'COLUMN2' }}
    </th>
    </tr>
</thead>
<tbody>
    <tr *ngFor="let item of mf.data">
        <td>{{ item.column1 }}</td>
        <td>{{ item.column2 }}</td>
    </tr>
</tbody>
</table>

My component contains the doStuff method but all I do is currently log something to the console. This is where the API call for the next page would be, if the event worked, that is:

export class TerminalStandardComponent implements OnInit, AfterViewInit {
  tableData: any[];

  doStuff(ev) {
    console.log(ev);
  }
}
question from:https://stackoverflow.com/questions/65908145/pascalhonegger-ng-datatable-onpagechange-isnt-triggered

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...