FIX: ExpressionChangedAfterItHasBeenCheckedError

This commit is contained in:
Patrick Haßel 2025-11-21 10:20:59 +01:00
parent 9f24ea08ae
commit b2a96e1c24
3 changed files with 13 additions and 4 deletions

View File

@ -26,7 +26,9 @@
<div class="MainMenuDrawer NoUserSelect" [hidden]="!showDrawer"> <div class="MainMenuDrawer NoUserSelect" [hidden]="!showDrawer">
@for (location of locationList; track location.id) { @for (location of locationList; track location.id) {
<div class="MainMenuItem" (click)="navigate(`Location/${location.id}`); showDrawer = false" routerLinkActive="MainMenuItemActive">{{ location.name }}</div> @if (location.id !== locationService.id) {
<div class="MainMenuItem" (click)="navigate(`Location/${location.id}`); showDrawer = false" routerLinkActive="MainMenuItemActive">{{ location.name }}</div>
}
} }
</div> </div>

View File

@ -79,14 +79,13 @@ export class LocationDetail implements OnInit, OnDestroy {
} }
ngOnInit(): void { ngOnInit(): void {
this.locationService.id = null;
this.subs.push(this.activatedRoute.params.subscribe(params => { this.subs.push(this.activatedRoute.params.subscribe(params => {
const id = paramNumberOrNull(params, "id"); const id = paramNumberOrNull(params, "id");
if (id === null && this.configService.locationId !== null) { if (id === null && this.configService.locationId !== null) {
this.router.navigate(["Location/" + this.configService.locationId]); this.router.navigate(["Location/" + this.configService.locationId]);
return; return;
} }
this.locationService.id = id; setTimeout(() => this.locationService.id = id, 0);
})); }));
this.subs.push(this.locationService.location$.subscribe(this.onLocationChange)); this.subs.push(this.locationService.location$.subscribe(this.onLocationChange));
} }

View File

@ -5,6 +5,14 @@ import {Injectable} from '@angular/core';
}) })
export class MenuService { export class MenuService {
title: string = ""; private _title: string = "";
get title(): string {
return this._title;
}
set title(value: string) {
setTimeout(() => this._title = value, 0);
}
} }