angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

Angular2 {{interpolation}} doesnt work in columns.render()

Open doink1985 opened this issue 9 years ago • 1 comments

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?

  1. Component someValue:any = 22; // here is my value

  2. 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}}
 }
},
...
]
}

doink1985 avatar Nov 16 '17 08:11 doink1985

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.

l-lin avatar Nov 24 '17 20:11 l-lin