My goal is to utilize a service within another service in order to translate strings found within exported constants.
This is how my code currently appears in a simplified form:
// 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 am encountering an error as the injected service is not recognized outside of the component:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'injectedService' of undefined
I am seeking advice on the optimal solution to resolve this issue. What steps can be taken to address this problem effectively?