In order to capture the data from a custom component, you need to define it in the settings of a smart table within the parent component.
setting.columns.button: {
title: 'Actions',
filter: false,
type: 'custom',
renderComponent: ActionButtonComponent,
onComponentInitFunction(instance) {
instance.save.subscribe(row => {
console.log(this)
});
}
}
As for the child component:
@Component({
selector: 'app-action-button',
template: `
<span ngbDropdown>
<button class="btn btn-danger btn-raised mr-1" id="dropdownRaised4" ngbDropdownToggle>Actions</button>
<div ngbDropdownMenu class="dropdown-menu-right" aria-labelledby="dropdownRaised4">
<button class="dropdown-item ontop" (click)="onClick(event)">
<i class="icon-x"></i>Cancel</button>
</div>
</span>`,
styleUrls: ['./action-button.component.scss']
})
export class ActionButtonComponent implements ViewCell, OnInit {
renderValue: string;
@Input() value: string | number;
@Input() rowData: any;
@Output() save: EventEmitter<any> = new EventEmitter();
ngOnInit() {
this.renderValue = this.value.toString().toUpperCase();
}
onClick(row) {
this.save.emit(row);
}
}