I'm not very familiar with ionic, but I have a question on behalf of my friend who is hesitant to ask on StackOverflow because she's unsure of how to frame her question.
She simply wants to learn how to implement a submenu in an ionic 2 side menu starter project.
The HTML
<ion-menu [content]="content" side="left" id="menu1">
<ion-content class="outer-content" no-border-top>
<ion-list lines (click)="openSubCat($event,category)">
<ion-list-header>
Shop For
</ion-list-header>
<ion-item *ngFor="let item of categoryArray" let idx=index (click)="openSubCat(item.value)">
<ion-icon [name]="item.icon" item-left></ion-icon>
{{ item.value }}
<ion-icon [name]="item.icon2" item-right ></ion-icon>
</ion-item>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>`
the app-components.ts
import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { TutorialPage } from '../pages/tutorial/tutorial';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = TutorialPage;
pages: Array<{title: string, component: any}>;
categoryArray: Array<any> = [{
value:'Men',
icon: 'man',
icon2:'ios-arrow-forward-outline',
view:'viewToGoTo'
},{
value:'Woman',
icon: 'woman',
icon2:'ios-arrow-forward-outline',
view:'viewToGoTo'
},{
value:'Kids',
icon: '',
icon2:'ios-arrow-forward-outline',
view:'viewToGoTo'
}
];
constructor(public platform: Platform) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
Splashscreen.hide();
});
}
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
openSubCat(category){
console.log(category)
}
}
I provided her with this link, but couldn't explain much as I don't have much experience with ionic. It seems that creating a dropdown requires a 2d array, is that correct? Could someone please enhance the code in this question by adding a submenu example for her learning?