So I have this code:
Controller:
vm.dtColumns = [
DTColumnBuilder.newColumn('product_code').withTitle('Code'),
DTColumnBuilder.newColumn('product_name').withTitle('Name'),
DTColumnBuilder.newColumn(null).withTitle('Actions').notSortable()
.renderWith(function(data, type, full, meta) {
return ` <button class="btn btn-info btn-raised" ng-click="openViewProductModal(${data.product_id})">View</button>`;
})
];
$scope.openViewProductModal = function(id) {
console.log(id)
}
HTML:
<div ng-controller="ProductCtrl as productControl" ng-init="loadProducts()">
<table datatable="" dt-options="productControl.dtOptions" dt-columns="productControl.dtColumns" dt-instance="productControl.dtInstance" class="row-border hover"></table>
</div>
I can't even get the console.log() to work though everything is rendered perfectly. Am I missing something here?
ng-click. The click won't activate on its own. You need to $compile stuff : docs.angularjs.org/api/ng/service/$compile