Reputation: 13765
I'm working on dashboard for monitoring jobs and the status is updated
butt the cellTemplate
in Ui-Grid does not behave as expected
here what I have tried
$scope.gridOptions = {
columnDefs: [{
field: 'Id'
}, {
field: 'Job'
}, {
field: 'status',
cellTemplate:'<div>{{grid.appScope.applyStatus(row.entity.status)}}</div>'
//note this work well
// cellTemplate:'<div><i class="fa fa-circle-o-notch fa-spin"></i></div>'
}]
};
and this function should update the status with a fontawesome Icon
$scope.applyStatus= function(status) {
switch(status)
{
case "Pending" :
return '<i class="label-info fa-pause" />';
case "Running" : return '<i class="label-primary fa-play-circle-o" />'
case "Error" :
return '<i class="label-danger fa-bug" />';
default:
return '<i class="label-default fa-box fa fa-question"/>';
}
return
};
But instead of rendering what I expected Angulars treat this as if a text
here a plunker http://plnkr.co/edit/7UapXgNzZWPXVZbLjYFy?p=preview
any help with a good underhood explanation will be appreciated
Upvotes: 0
Views: 316
Reputation: 886
Here is a way of doing it using ng-class. http://plnkr.co/edit/lRuP4agztDo7kxEO5VE6?p=preview
CellTemplate:
<div><text><i ng-class="grid.appScope.applyStatus(row.entity.status)"/></text></div>
Upvotes: 2