dev*_*per 2 typescript ag-grid angular
有谁知道如何从Angular2 +中的ag-grid的ValueFormatter调用服务?
例:
我在构造函数中注入了一个名为someService的服务,并希望从ValueFormatter中调用该服务。我应该怎么做才能做到这一点?
constructor(private service: SomeService) { }
this.columnDefs.push(
{
headerName: 'Date',
width: 150,
field: 'incidentDate',
valueFormatter(params) {
return this.service.doSomething(params.value);
}
});
Run Code Online (Sandbox Code Playgroud)
目前,它无法识别来自valueFormatter的服务。
提前致谢
我已经找到解决问题的办法。我只需要执行以下操作:
this.columnDefs.push(
{
headerName: 'Date',
width: 150,
field: 'incidentDate',
valueFormatter: this.anotherFunction.bind(this)
});
anotherFunction(params): string {
return this.service.doSomething(params.value);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1556 次 |
| 最近记录: |