Like the post that you comment: How to Update a Component without refreshing full page - Angular
You should use a BehaviorSubject.
Let's says that you had a Service that has the BehaviorSubject.
CustomService:
@Injectable()
export class CustomService {
public isLoggedIn$: Observable<boolean>;
private _sourceUserLoggedIn = new BehaviorSubject<boolean>(false);
constructor() {
this.isLoggedIn$ = this._sourceUserLoggedIn.asObservable();
}
setLoggedIn(value: boolean): void {
this._sourceUserLoggedIn.emit(value);
}
}
Then in the AppComponent.ts
export class AppComponent {
constructor(private customService: CustomService) {}
public get isLoggedIn$(): Observable<boolean> {
return this.customService.isLoggedIn();
}
}
Finally in the AppComponent.html
<app-menu *ngIf="this.isLoggedIn$ | async"></app-menu>
<router-outlet></router-outlet>
That's should work.