Dynamically add items to Ionic 2 side menu
See original GitHub issueI am using latest version of ionic 2.
Ionic version: 2.1.8
I want to add item dynamically in a sidebar.
app.component.ts;
export class MyApp {
pages: Array<{title: string, component: any, icon: any }>;
this.pages = [
{ title: 'Dashboard', component: DashboardComponent, icon: 'ios-home-outline' },
{ title: 'Complaints', component: ComplaintPage, icon: 'ios-sad-outline' },
{ title: 'Suggestions', component: SuggestionPage, icon: 'md-bulb' },
{ title: 'Appreciations', component: AppreciationPage, icon: 'ios-thumbs-up-outline' },
{ title: 'Poll', component: PollPage, icon: 'ios-stats-outline' },
{ title: 'Survey', component: SurveyPage, icon: 'ios-analytics-outline' },
{ title: 'ReportIssue', component: ReportIssuePage, icon: 'ios-bug-outline' },
];
}
app.html
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
<ion-icon item-left [name]="p.icon"></ion-icon>
{{p.title}}
</button>
</ion-list>
</ion-content>
I want to show complaint item if complaint status is ‘NEW’.
So, Is it possible to showing complaint item for some specific condition? I tried with ngIf but its do not work.
what is the best way to implement this kind of features?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Change side menu items dynamically in Ionic 5 - Stack Overflow
Create event service. In the EventService.ts: export class EventService { private dataObserved = new BehaviorSubject<any>(''); currentEvent ...
Read more >Add Dynamic Side Menu in Ionic 6 App with Active Class
A comprehensive Ionic step by step tutorial, Learn how to implement side menu dynamically in Ionic app with active class for selected page....
Read more >Dynamically add items to Ionic 2 side menu #9791 - GitHub
I am using latest version of ionic 2. Ionic version: 2.1.8 I want to add item dynamically in a sidebar. app.component.ts; export class...
Read more >How to dynamically show an ion-menu in Ionic 4 - Jordan Benge
First things first. Generate a new component called side-menu by using ionic g component components/side-menu This is going to house our ion ......
Read more >Dynamically Adding ion-menu in app.component.html
I am just getting started with ionic-4 and wanted to know how could I generate the code needed for ion-menu and insert it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi Tusharbalar, how did you get this solved. Kind Regards
Hello @mainakanyi, I have implemented the same thing, and it’s working correctly in my app
.ts file
HTML file
let me know if you are not able to do this thing, i will provide more code