For over two years, I've been using the code below for a side menu in Ionic up to version 5. However, after updating to Ionic 6.20.6 and Angular 15^, I encountered the following error:
else { this.showLevel1 = idx; }
Type 'string' is not assignable to type 'null'.ts(2322)
export class AppComponent {
public appPages: any;
showLevel1 = null;
showLevel2 = null;
@ViewChildren(IonRouterOutlet) routerOutlets: QueryList<IonRouterOutlet>;
clearLevel() {
this.showLevel1 = null;
this.showLevel2 = null;
// this.showLevel3 = null;
}
toggleLevel1(idx: string) {
if (this.isLevel1Shown(idx)) {
this.showLevel1 = null;
} else {
this.showLevel1 = idx;
}
}
isLevel1Shown(idx: string) {
return this.showLevel1 === idx;
}