I have an application written in Angular 13 using Typescript.
I want to hide items with get url parameters and set it to true if it doesn't exist.
export class AppComponent {
menu: boolean = true;
constructor(private oauthService: InitialAuthService, private userRoleService: UserRoleService, private route: ActivatedRoute,) {
}
ngOnInit(): void {
this.route.queryParams
.subscribe((params: any) => {
this.menu = !!params["menu"] ? params["menu"] : true
}
);
this.menu = this.route.snapshot.queryParams['menu'];
I simply want to cache HTML element following parameters obtained in URL.
For example
http://localhost:4200/index?menu=false // hide menu
http://localhost:4200/index?menu=true // show menu
http://localhost:4200/index // show menu
html side
<div *ngIf="menu">...</div>