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

Subscribe to selectionChange event #3

Closed m-s-sh closed 7 years ago

m-s-sh commented 7 years ago

If you do <ng2-md-datatable [selectable]="true" (selectionChange)="onSelectionChange($event)">, angular report a error because in that time selectionChange is undefined.

if you move the initialization code from ngOnInit to constructor(MdDataTableComponent), it is working.

ngOnInit() {
    this.selectionChange = new EventEmitter<IDatatableSelectionEvent>(true); // async
    this.sortChange = new EventEmitter<IDatatableSortEvent>(true); // async

Or may be I am wrong?

fredguile commented 7 years ago

Good finding, that is most probably right. I'll fix this in next release!