I would like to inject a service into another service with which I want to translate strings within exported constants.
My code currently looks like this (I've simplified it here)
// Imports..
@Injectable(
{ providedIn: 'root' }
)
export class MyService {
constructor(private httpClient: HttpClient, private injectedService: InjectedService) {
}
// Methods..
}
export enum Series {
prop_1 = 'String_1',
prop_2 = 'String_2',
prop_3 = 'String_3',
}
export const ALL_SERIES: Series[] = [
this.injectedService.translate(Series.prop_1),
this.injectedService.translate(Series.prop_1),
this.injectedService.translate(Series.prop_1),
];
However, I get this error because the injected service is not detected outside the component:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'injectedService' of undefined
What would be the cleanest solution to this problem?