You can inject the dependency in the constructor like this:
export class ExponentialStrengthPipe implements PipeTransform {
constructor(public testService: TestService) {
}
transform(value:number, args:string[]) : any {
// you can access this.testService here
return Math.pow(value, parseInt(args[0] || '1', 10));
}
}
Don’t forget to make sure you add this dependency to the app module:
@NgModule({
declarations: [...],
imports: [...],
providers: [..., TestService],
bootstrap: [AppComponent],
}