irossimoline / angular4-material-table

Angular 4 table based on @angular/cdk table structure, to allow row insertion, edition, validation and deletion.
MIT License
55 stars 25 forks source link

How to create a method in component of row.confirmEditCreate() #27

Closed harshthakur92 closed 5 years ago

harshthakur92 commented 5 years ago

.html <button *ngIf="row.editing" mat-icon-button color="primary" focusable="false" (click)="row.confirmEditCreate()">

.component.ts how can i call this method confirmEditCreate(){ //It gives an error } By calling this method i will save data in to the database.

@irossimoline Please help

irossimoline commented 5 years ago

Hi @harshthakur92,

In that case you must call the method with the row as a parameter, as follows:

<button *ngIf="row.editing" mat-icon-button color="primary" focusable="false" (click)="row.confirmEditCreate()">
confirmEditCreate(row: TableElement){
  // Do whatever you need before
  // calling the row method.
  const result = row.confirmEditCreate();
  // You also can use the result 
  // of the operation (boolean).
}

Hope it helps, if you have any other doubt please reach me out.

irossimoline commented 5 years ago

As the answer seems to fix the issue, I'll close it.

If you have additional questions please feel free to open a new issue.

Regards!