I often find that developers do not use the binding and change detection available in Angular and basically bypassing it using Themes when they really don't need it.
For example, I have a full thematic example of Subject / Behavior: https://github.com/DeborahK/MovieHunter-communication in the MH-Take3 folder.
Then I get exactly the same functionality using simple properties in the MH-Take4 folder without a Subject / BehaviorSubject and code that is slightly smaller.
However, I would recommend wrapping your service property in a component property so that your template does not need information about your service. This is not required, but provides good encapsulation.
For instance:
get showImage(): boolean { return this.movieParameterService.displayPosters; } set showImage(value: boolean) { this.movieParameterService.displayPosters = value; }
I have a parameter service that saves parameters for one of my views. In this case, it saves whether the image display is turned on or off. I set the service parameter using the getter and setter in the component. Thus, the template is attached to the component and does not need knowledge about the service.
In addition to the main advantages of encapsulation, it also simplifies the use of editor features such as Find All Links, as it will find components that use this service. It will not find if the only link is in the lines in the template.
source share