Adding an icon to CellTemplate
I'm trying to have a table that has the cell template to display icons and the column information:
$scope.genderTemplate = '<i class="fa fa-{{COL_FIELD}}"></i>{{COL_FIELD}}' ;
Accessed by:
$scope.gridOptions.columnDefs = [
{ name: 'name' },
{ name: 'gender', cellTemplate:genderTemplate},
{ name: 'ShowScope',
cellTemplate:'<button class="btn primary" ng-click="grid.appScope.showMe()">Click Me</button>' }
];
But the table does not show up.
Here is the plnkr: http://plnkr.co/edit/ufMcRpXN2y0mXmZdK17V?p=preview
You hadn't saved your plunker, so I'm assuming the problem was probably a typo somewhere in the plunker.
Here's an updated one with the code you suggest above, and it seems to work fine: http://plnkr.co/edit/MaSuKSnk7HvdjK4DERlR?p=preview
It must have been a typo...
Is it possible to have the icon only show based on the content of COL_FIELD? For example, only show when it is a female?
cellTemplate: '<div ng-show="{{COL_FIELD}}=="female""><i class="fa fa-{{COL_FIELD}}"></i>{{COL_FIELD}}</div>'
http://plnkr.co/edit/JLm5GS5J8530Rutjly31?p=preview
That should also work, yes, but I think you don't use a binding inside ng-show, so it would be COL_FIELD === 'female'
Ah, thank you :D That worked out great.