Does anyone know how to call service from ValueFormatter of ag-grid in Angular2+?
Example:
I have injected a service called someService in the constructor and would like to call the service from the ValueFormatter. What should i do to achieve that?
constructor(private service: SomeService) { }
this.columnDefs.push(
{
headerName: 'Date',
width: 150,
field: 'incidentDate',
valueFormatter(params) {
return this.service.doSomething(params.value);
}
});
At the moment, it doesn't recognise the service from the valueFormatter.
Thanks in advance
I have found a solution to my problem. I simply need to do the following:
this.columnDefs.push(
{
headerName: 'Date',
width: 150,
field: 'incidentDate',
valueFormatter: this.anotherFunction.bind(this)
});
anotherFunction(params): string {
return this.service.doSomething(params.value);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With