Ionic3-MultiLevelSideMenu
Ionic3-MultiLevelSideMenu copied to clipboard
Add new id property to SideMenuOption interface
Even though it's easy to use the displayText
to decide which option/suboption should be marked as selected, it'd be better if the component allow users to add an id
to each option/suboption and then use that id
instead of the displayText
.
For example:
public enum SideMenuPage {
AdminDetails,
UserDetails
}
// ...
const options: Array<SideMenuOption> = [
{
displayText: 'Admin',
suboptions: [
{
id: SideMenuPage.AdminDetails,
displayText: 'Details',
component: 'DetailsPage',
// ...
},
// ...
]
},
{
displayText: 'User',
suboptions: [
{
id: SideMenuPage.UserDetails,
displayText: 'Details',
component: 'DetailsPage',
// ...
},
// ...
]
}
]
And then:
@Component({
selector: 'page-details',
templateUrl: 'details.html'
})
@SideMenuDisplayTextConditions([
{ propertyName: 'userType', matcher: Matcher.ToEqual, value: UserType.Admin, optionId: SideMenuPage.AdminDetails },
{ propertyName: 'userType', matcher: Matcher.ToEqual, value: UserType.User, optionId: SideMenuPage.UserDetails }
])