Is it possible to pass a boolean variable up to a parent router-outlet component?

Discussão em 'Angular' iniciado por Rick, Abril 11, 2025.

  1. Rick

    Rick Guest

    The basic idea is that I want a "Loading" text to display while the child component is loading data, and then go away once it's finished. But how can the parent component know when the child has finished loading data?

    My parent looks like this:

    <div *ngIf="isLoadingFlg">Loading...</div>

    <router-outlet></router-outlet>


    Somehow I need the child component to be able to set the parent's isLoadingFlg. Child looks like this:

    ngOnInit() {
    this.isLoadingFlg = true;
    setTimeout(() => {
    this.isLoadingFlg = true;
    }, 1000);
    }

    Continue reading...

Compartilhe esta Página