I have a Web App in Angular2, in which I am using the SmartAdmin template. One of my templates has a datatable.
For each record in the table, I want to have an 'Edit' button.
This is how I did it -
<sa-datatable #countryTable [options]="{
ajax: 'assets/api/tables/datatables.filters.json',
columns: [ {data: 'name'},
{data: 'position'},
{data: 'office'},
{data: 'age'},
{data: 'date'},
{data: 'salary'},
{defaultContent: '<button class=\'btn btn-default btn-xs edit-country-btn\' (click)=\'editClicked()\'>Edit</button>' } ] }"
tableClass="table table-condenced table-striped table-bordered">
.
.
.
</sa-datatable>
The problem is that the button is rendered, but the event is not bound to it. (The HTML is rendered as it is, without Angular2 directives).
I tried rendering the button using render instead of defaultContent. But that doesn't work as well.
EDIT
I tried to get the edit-country-btn elements from the DOM in order to bind them to the event, but I can't seem to fetch them:
In the component -
@ViewChild('countryTable') public countryTable: any;
ngAfterViewInit() {
var b = this.countryTable.el.nativeElement.querySelectorAll('button');
console.log(b);
}
The result is a list of buttons, but not the edit buttons that I want.