angular-datatables
angular-datatables copied to clipboard
Angular2 {{interpolation}} doesnt work in columns.render()
Before you write your question, please take some extra time to write a good title that is short yet descriptive.
What versions you are using?
- node version: v8.1.2
- npm version: 5.4.2
- angular version: v1.5.8
- jquery version: ~1.12.3
- datatables version: ^1.10.16
- angular-datatables version: ^4.4.0
- angular-cli version: 1.4.5
What's the problem?
Hi. I need to use interpolation {{someValue}} in dtOptions.columns.render(). Actually I started from the easiest way, by in future I would like to integrate directives and components in column descriptions. I hope the code below will make clear my idea. thanks in advance!
Can you share your code?
-
Component someValue:any = 22; // here is my value
-
Service
dtOptions = {
dom: 'Brptip',
columns = [
{
title: 'Document',
data: 'ticket',
render: (val, type, row, meta) => {
return span>{{someValue}}</span // -- that is a place that doesn't work. When the Table is created, I expect here to be '22' instead {{someValue}}
}
},
...
]
}
You should concatenate your someValue with your html:
render: (val, type, row, meta) => {
return '<span>' + sameValue + '</span>';
}
If you want to go further (like adding events), check #982.