I want to share a signal between components aross my application, alternatives to service...

Discussão em 'Angular' iniciado por Naren Murali, Janeiro 27, 2025.

  1. Naren Murali

    Naren Murali Guest

    My scenario is, I have a dialog, which is opened through a signal, but I want to trigger this dialog to open, across my application. The obvious way is to create a DialogService (providedIn: 'root') and store the signal there, but is there a more lightweight way to achieve the same.

    Dialog component HTML:


    @if(showDialog()) {
    <kendo-dialog
    title="sometitle"
    >
    some text
    </kendo-dialog>
    }

    Dialog Component TS:


    @Component({ ... })
    export class DialogComponent {
    showDialog = signal(false); // <-- I want to share this signal, across multiple components.
    }


    Version is Angular 19 but am ok with something that is backwards compatible also.

    Continue reading...

Compartilhe esta Página