mercredi 25 avril 2018

How to add checkbox in ng2-table in Angular-4?

I need to add checkbox in Angular 4 typescript we are using ng2-table.

//code for ng-table in html
<ng-table (tableChanged)="onChangeTable(config)"
(cellClicked)="onCellClick($event)"
[rows]="rows" [columns]="columns">
</ng-table>

//to create checkbox I am adding html in component where filling the data.
data.forEach((item: any) => 
{item.CheckBox = '<input type="checkbox"></input>';

//cell click event in table component is getting triggered
public onCellClick(data: any): any {
     this event is getting triggered
     ....
}

  1. Check box on UI is disabled or not able to checked. I think some event is getting triggered and reverting selected value to false each time. How to prevent that?
  2. Where do I bind this check box to ng-model or similar?

Please help. Thanks you.




Aucun commentaire:

Enregistrer un commentaire