In Ionic, I need to add dynamically some elements in the side menu.
When a user log in, I need to show the modules of the user, I get them from an API, but I don't know how to add them to the side menu list.
I have read some docs, but I can't find how to add them, what I do now is to show the modules in the welcome screen but that's not good.
I'm using Ionic 3.15.2
I have done something related to your requirement; I built a service to get sidemenu options from server after user logs in.
high level steps;
Login:
import { Events } from 'ionic-angular';
constructor:
public events: Events
//after user login publish the event
this.events.publish('userlogin');
app.components.ts:
import { Events } from 'ionic-angular';
constructor:
public events: Events;
//subscribe the previous event in constructor and add below in constructor
this.events.subscribe('userlogin',(() => {console.log('Got Events');
this.getDynamicMenuOptions(); // this method gets dynamic side menu options from server }));