I need to show elements of the side menu according to the role of the user. then I look in app.html if the page shows the items corresponding to the role. but it does not show elements in the side menu just after logging in, but after updating the application with the browser's Refesh button it shows the correct elements as it should. I guess the problem is Ionic: How can I update the application so that new menu items appear?
Every time I log in with another user / role, it shows the menu according to the previous user / role.
app.component.ts
if (this.userData.roles["0"]["name"] == "bikeuser") {
this.pages = [
{ title: "Mi perfil", icon: 'contact', component: ProfilePage },
{ title: "Solicitar", icon: 'bicycle', component: RequestAngelPage },
{ title: "Seguimiento", icon: 'photos', component: TrackingCardPage },
{ title: "Terminados", icon: 'close-circle', component: RequestFinishBikeuserPage }
];
else if (this.userData.roles["0"]["name"] == "Biciangel") {
this.pages = [
{ title: "Mi perfil", icon: 'contact', component: ProfilePage },
{ title: "Sin asignar", icon: 'body', component: UnassignedRequestsPage },
{ title: "Asignadas", icon: 'people', component: RequestsPage },
{ title: "Terminados", icon: 'close-circle', component: RequestFinishedPage }
];
}
app.html
<button ion-item detail-none *ngFor="let page of pages" (click)="openPage(page)">
<ion-icon *ngIf="page.icon" name="{{page.icon}}" item-left></ion-icon>
{{page.title}}
</button>
That is, if login does not show My profile. But when I give update to the browser if it shows the item my profile and the other items. Please an explanation according to what I have just placed because I have searched the internet and I can not find anything about it.