passing an Angular Signal Input value from a service into a component

Discussão em 'Angular' iniciado por mideo mideo, Novembro 25, 2024.

  1. mideo mideo

    mideo mideo Guest

    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 ?
    ​

    Continue reading...

Compartilhe esta Página