How to call a function on column.render() ?
How to call a function on column.render() ?

Hi,
I'm using Angular datatables for my angular app and i want to call a function on one of my column.render() to have something like :
columns: [{
title: 'My Column name',
data: 'id',
render (data){
return this.usersService.getUserName(data);
}} }],
usersService is initate on my constructor() but when i trying to do that, i cant call usersService.
I have this error :
ERROR TypeError: Cannot read property 'usersService' of undefined
My dtOption is on ngOnInit().
If someone can help me..
Thanks,
Nick
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The execution scope is wrong - try:
I believe that the short hand you are using expands to:
hence why
this
changes. You want a fat arrow function to execute in the same scope as your parent function.Allan
Thank you ! It works !
Nick