fredguile / ng2-md-datatable

Angular 5+ DataTable component for using with Material Design 2
https://www.npmjs.com/package/ng2-md-datatable
MIT License
38 stars 13 forks source link

How to bind these two table and pagination components and how to use its events #16

Closed RohitLuthra19 closed 7 years ago

RohitLuthra19 commented 7 years ago

HI, I am new to angular2, just started learning it. Please anybody can help me. How to use ng2-md-datatable-pagination component with ng2-md-datatable component and how to use following events

@Output() selectionChange: EventEmitter; @Output() sortChange: EventEmitter; @Output() paginationChange: EventEmitter;

fredguile commented 7 years ago

I've made an Angular CLI App that shall help you to integrate it, you can check it out here: https://github.com/fredguile/ng2-md-datatable/tree/master/demo-app

That's a good example to check how to connect everything together.

In the demo-app, I use a "naive" approach using a service (AppService) that synchronously returns some data from a static array.

In real world, you would probably query an API and asynchronously return the results. In this case your service methods must return a Promise (or an Observable if you feel it's worth the journey). The difference in your template isn't much, you would simply use the AsyncPipe before iterating over the results.

fredguile commented 7 years ago

I'll close due to inactivity, please reopen if questions.