I am working on angular project when I am adding new row in table I am getting proper data in my service but in table it is showing 2 times.
Above is my smart table code.
<ng2-smart-table [settings]="settings" [source]="source" (createConfirm)="onCreateConfirm($event)">
</ng2-smart-table>
Following is the function on save.
add: {
addButtonContent: '<i class="nb-plus"></i>',
createButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmCreate: true,
},
onCreateConfirm(event): void {
if (window.confirm('Are you sure you want to create?')) {
event.newData['name'] += ' + added in code';
event.confirm.resolve(event.newData);
CoursesService.addNewCourse(event.newData);
} else {
event.confirm.reject();
}
}
}
The addNewCourse function in service is as follow,
static addNewCourse(data)
{
this.coursedata.push(data);
console.log(this.coursedata);
}
In coursedata I am getting data only one time while in table it is showing 2 times
any help?