Ответ 1
Вы можете вставить зависимость в конструктор следующим образом:
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));
}
}
Не забудьте убедиться, что вы добавили эту зависимость в модуль приложения:
@NgModule({
declarations: [...],
imports: [...],
providers: [..., TestService],
bootstrap: [AppComponent],
}