I have a situation where I want to be able to have multiple widget components used on the page at the same time. I want to isolate the ContainerComponent dependencies so that each ContainerComponent instance references unique service instances.
For example I would like every instance of the following component to have a unique instance of the "FhirService":
export class ContainerComponent implements OnInit, OnDestroy, AfterViewInit {
...
constructor(private _fhir: FhirService, private _questionnaireService: QuestionnaireService, private cdr: ChangeDetectorRef) {}
Service definition:
@Injectable({
providedIn: 'root'
})
export class FhirService {
public guidanceResponseBS: BehaviorSubject<GuidanceResponse>;
constructor(private _http: HttpClient, private _settingsService: SettingsService) {
this.guidanceResponseBS = new BehaviorSubject<GuidanceResponse>(null);
}
...
How is this done?