export class SpecificComponent implements AfterViewInit, OnDestroy {
/** Component configuration object */
ConfigData = input.required<Config>();
// some code
}
Assuming I have Angular components using Signal Input, and I manage these components in a service as follows:
export class SpecificService {
private specificComponentRef: ComponentRef<SpecificComponent> | null = null;
SpecificMethod(config: Config) {
// some code
// Correctly set the value for InputSignal
this.specificComponentRef.instance.ConfigData.set(config);
// some more code
}
}
I attempt to set the ConfigData Signal Input like this:
this.specificComponentRef.instance.ConfigData.set(config);
However, I encounter the error: Property 'set' does not exist on type 'InputSignal'.ts(2339). What is the correct way for passing ConfigData Signal Input value from a service into the component ?
If you have access to ComponentRef
you should call setInput
.
in your case :
this.specificComponentRef.setInput('ConfigData', whateverValue)