I have developed a theme change service for switching icons. Within my theme service, I use BehaviorSubject to manage the path of icons - light theme icons are stored in "assets/light-icons" and dark theme icons are stored in "assets/dark-icons." I inject my service into every component's constructor, passing the folder name as a string based on the selected theme.
Here is an example TypeScript class:
constructor(public themeService: ThemeService) {}
And here is an example HTML class:
<img [src]="'assets/'+themeService.functionWhichReturnsSubjectValueAsString+'/target_icon.svg'">
While this solution works well, I am curious if there is a more efficient approach. Currently, I need to inject my service in each component that contains icons or images. Is it possible to manage this at the parent level?